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).
When creating an
elfio
object and then use it withstd::move
in the move constructor of a newelfio
object, the header, segment and section pointers of the original object aren't reassigned tonullptr
, thus causing them to get freed with the destructor of the original object is called. This causes the destructor of the secondelfio
object to throw anaccess violation
error when trying todelete
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 withstd::make_unique
and replace all raw pointers withstd::unique_ptr
s to allow for default move construction and assignment implementations (as present today).