Fixed a handful of potential memory leaks reported by clang static analysis.