ext: fix freeing garbage on typeerror fail