Fixed resource and memory leaks.

Fixed: log_location remained unclosed and fullpath memory has never
been freed.