Fixed bug #79951 One branch did not release tmp_replace_entry_str. Also reduce the scope of some variables.