fix use after free bug
Merge pull request #120 from regehr/fix

fix use after free bug