fixup use after free in script