fix memory leak on thrown exception
Merge pull request #4 from mscdex/master

fix memory leak on thrown exception