Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix dangling pointer and message in error.hpp. #432

Merged
merged 1 commit into from
Jun 2, 2015

Conversation

rec
Copy link
Contributor

@rec rec commented May 27, 2015

Two little problems still in this file.

  1. what() returns a const char* that comes from a std::string. If the std::string changes, the const char* might become invalid, resulting in undefined behavior.
  2. The first and second constructors of exception are inconsistent. In the first one, if there's no message the message from the error code is used. In the second one, there's no message, even though there's an error code provided.

My solution to the first problem was simply to make that one std::string member const. It will break any code that changes the m_msg on an exception - but if they did that, they were flirting with UB anyway - and everything else should work unchanged.

zaphoyd added a commit that referenced this pull request Jun 2, 2015
Fix dangling pointer and message in error.hpp.
@zaphoyd zaphoyd merged commit 2af2135 into zaphoyd:develop Jun 2, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants