Fix memory leak on thrown exception
Merge pull request #1 from mscdex/master

Fix memory leak on thrown exception