Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KYRA: Silence analysis tools about possible memory leaks
- Loading branch information
Johannes Schickel
committed
May 15, 2016
1 parent
109c54c
commit 3664caa
Showing
1 changed file
with
8 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3664caa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean to "silence"? There was a memory leak, you never release it, and copy in the object constructors the file names, leaving the original allocated memory intact.
Or am I missing something?
3664caa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I looked at your changes I assumed this was based on some static analysis tool output because the change looked blindly done and untested. Doing a test run with valgrind showed that it was now indeed suffering from use-after-free.
The object constructors kept the pointer around, they never did any copying. This is why this caused invalid reads when running the games: you released the memory even though it was still in use.
There still was the problem that the allocated memory did not get freed after use. The structures did handle both unmanaged pointers and managed pointers. There was no special handling to release unmanaged memory. I already fixed this leak case as a side effect in 2317e3f where now only managed memory is passed, which is what the code assumed.