Skip to content
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

Return a valid pointer from validator_error::what(). #1016

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

nlewycky
Copy link

stringstream::str() creates a temporary that is destroyed at the end of the full-expression (the semi-colon), and c_str() on that string returns a pointer internal to the string. This function returns a pointer to freed memory.

Spotted by clang warning:

error.h:51:12: warning: returning address of local temporary object [-Wreturn-stack-address]
    return ss.str().c_str();
           ^~~~~~~~
1 warning generated.

stringstream::str() creates a temporary that is destroyed at the end of the full-expression (the semi-colon), and c_str() on that string returns a pointer internal to the string. This function returns a pointer to freed memory.

Spotted by clang warning:
```
error.h:51:12: warning: returning address of local temporary object [-Wreturn-stack-address]
    return ss.str().c_str();
           ^~~~~~~~
1 warning generated.
```
@nlewycky
Copy link
Author

I think the CodeQL check failure isn't due to this PR:

  Makefile:29: *** STOKE_PLATFORM is not set.  Did you run ./configure.sh?.  Stop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant