serge1 / ELFIO

ELFIO - ELF (Executable and Linkable Format) reader and producer implemented as a header only C++ library
http://serge1.github.io/ELFIO
MIT License
720 stars 155 forks source link

Explicit = Operator for elfio Segfault #68

Closed foreverska closed 3 years ago

foreverska commented 3 years ago

Correct me if I'm wrong but ELFIO::elfio seems to have an explicit = operator which does a shallow copy of pointers within the object. This causes a segfault on second deconstruction if you happen to use it.

It should probably be explicitly deleted, a deep copy implemented or a solution which can survive a shallow copy (thread safety + shared pointers).

serge1 commented 3 years ago

Thank you for mentioning this. Indeed, the copy constructor and assignment operator are not supported. I have added their deletion in commit 29114f65.

Please let me know your results.

pavelkryukov commented 3 years ago

I propose following Rule of Five to the end and define move ctor and assignment operator, at least with = default; syntax.

serge1 commented 3 years ago

Hi @pavelkryukov, thank you for the advice. The move constructor and assignment are implemented in f591a3b7. Just to make sure - is this what you meant?

pavelkryukov commented 3 years ago

Yes, looks great.

serge1 commented 3 years ago

Please reopen if you feel that the issue still persists