-
Notifications
You must be signed in to change notification settings - Fork 102
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
unsafe string operation? #87
Comments
The call to system() is safe but two temporary std::strings are created, one for logging and one for invoking system(). So the proposed replacement code is slightly more efficient. The temporary in the current call to system() lives to the end of the statement, after system() returns. So the C string will remain valid for the duration of the call. |
I thought the temporary instance was only guaranteed to live long enough to call "c_str()". |
Temporary objects are released at the end of a full-expression- in this case after the function call. |
I had a bug like this a LONG time ago before preserving temporary objects was a thing. |
ndppd/src/session.cc
Line 212 in 4f0301f
I believe this line may be unsafe as there is no guarantee that the temporary instance of std::string (and therefore the buffer returned by the c_str() function) persists for the length of the call to system()
I propose the following change:
The text was updated successfully, but these errors were encountered: