fix a potential use_after_free
Merge pull request #199 from felixonmars/dev

fix a potential use_after_free by felixonmars