Fix resource leaks found by Coverity.

Not a huge deal since these functions were really only called by
internal main2() methods, but good to fix these errors and silence the
messages.