Fix some memory leaks found by smatch.