Menu

#251 TProfile has a hazardous copy-constructor

unspecified
open
nobody
API (55)
1
2014-10-10
2014-03-28
No

TProfile has a default copy-constructor which does the wrong thing, leading to sharing of the internal state (C-strings) and double destruction.

TProfile should be made non-copyable or perform deep-copy of the internal state (e.g. by using owl::tstring instead of C-strings, thus eliminating the need for a custom destructor).

In particular, TProfile is currently unsafe if used in the C++11 auto-declaration style:

auto p = TProfile ("Section", "file.ini");

This will lead to a crash. If TProfile is made non-copyable, a move-constructor is needed to allow this style.

Discussion


Log in to post a comment.