fix memory leaks detected by coverity.

@cswelcher