Fix memory leak on throw

Issue(s) found via [cppcheck](http://cppcheck.sourceforge.net/).