Corrected invalid use-after-free