serge1/ELFIO

Double free after move constructor

galjs opened this issue · 2 comments

galjs commented

When creating an elfio object and then use it with std::move in the move constructor of a new elfio object, the header, segment and section pointers of the original object aren't reassigned to nullptr, thus causing them to get freed with the destructor of the original object is called.
This causes the destructor of the second elfio object to throw an access violation error when trying to delete these pointers since they are already freed.

Suggested solution:
Implement a custom move constructor and move assignment operator that reassign these pointers to nullptr.

OR

Replace all occurrences of new in the code with std::make_unique and replace all raw pointers with std::unique_ptrs to allow for default move construction and assignment implementations (as present today).

Thank you for your suggestions. I am on it.

The issue has been address by commit 24d29a2 .