Fixed a memory leak detected with valgrind.