sim_BuildROMs: Fix potential memory leaks