Fix some resource leaks on exception paths.

Found by Coverity.