These 2 patches fix two different memory leaks. If you run valgrind after applying the first patch you will still see memory leaks. The 2nd patch fixes the 2nd memory leak.