Fix the memory leak also in the new version.