Fix some function local pointer leaks (I am still learning C)