Fix memory leaks.

Found by: coverity scan