-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak in face of exceptions #118
Comments
Probably the least intrusive way is to use a temporary unique_ptr with a custom deleter:
Another way would be with try/catch:
Beyond that, it would probably require wrapping the m_value and m_type in a struct, and moving the basic_json destructor to the new struct. |
Yes, either should work, not quite sure which style the author prefers. |
nlohmann
added a commit
that referenced
this issue
Oct 3, 2015
exception-safe object creation, fixes #118
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The constructor often does a two-step initialisation, an
allocate()
followed by aconstruct()
. If theconstruct()
throws then the previously allocated memory will leak...The text was updated successfully, but these errors were encountered: