Fix some double-frees/use-after-free

r? @frank-trampe
Later? The function returns after that line.