Fix some double-frees/use-after-free

r? @frank-trampe
If we free/destroy ret and set it to null, we can get rid of the gotos, no?