Fix a memory leak and build warning.