Fix leak reported by valgrind