Fix memory leaks pointed out by Clang.