Call to elf_memory had no corresponding elf_end calls. Added elf_end calls to deallocate the memory at every return point.
Details
- Reviewers
- None
- Group Reviewers
Restricted Project
Diff Detail
Event Timeline
Previous fix was incomplete. Two exit points were overlooked (did not contain calls to elf_end).
Regarding Jon's suggestion to replace elf_end() by std::unique_ptr:
The libelf.h header file contains only a forward declaration of the Elf struct. The declaration itself is hidden in libelfP.h, which is not accessible. This causes an 'incomplete type' error in unique_ptr's dtor. Without a doubt, using unique_ptr would be the preferred solution. However, since it is not easily possible to make the declaration of the struct available, I would stick with the calls to elf_end().
Missing context in the diff (see https://llvm.org/docs/Phabricator.html) and missing reviewers.
Would be better to put an object on the stack the calls elf_end in the destructor than to wire it up to all the paths.
I think @jhuber6 has a patch in flight which will collide with this