sleuthkit/sleuthkit — pull request #329 by wsdookadr (2014-05-06 00:49:10+00:00)
Title: fixing memory leak

I found a memory leak in TskFsDir::getFile
I've also sent an e-mail to the dev mailing list sleuthkit-developers@lists.sourceforge.net describing
the leak and a fix for it.

When TskFsDir::getFile is called, it wasn't setting TskFsFile::m_opened to true, which in turn would mean that TskFsDir's destructor, and in turn, TskFsDir::close() wouldn't call tsk_fs_file_close. This was causing the leak.

I wrote a testcase to isolate the problem and used Valgrind and GDB to debug it.

This diagram shows all the callpaths to tsk_fs_file_alloc and tsk_fs_file_close on the testcase:

![gdb-all-paths](https://cloud.githubusercontent.com/assets/180373/2885015/8f8e8568-d4b7-11e3-9432-33b430f6be67.png)

This diagram shows the callpath that cause the memory leak:

![gdb-paths-that-caused-leak](https://cloud.githubusercontent.com/assets/180373/2885016/8f9369de-d4b7-11e3-972e-2d8787e0709d.png)