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

Use after free in Main.cpp #846

Open
mgehre opened this issue Aug 15, 2019 · 0 comments
Open

Use after free in Main.cpp #846

mgehre opened this issue Aug 15, 2019 · 0 comments
Labels
bug some feature is broken easy-fix

Comments

@mgehre
Copy link

mgehre commented Aug 15, 2019

On latest clang trunk, the code

const char *text = ("Content of this directory moved to " +
							                    xdg_data_home + "/openspades")
							                     .c_str();

in https://github.com/yvt/openspades/blob/master/Sources/Gui/Main.cpp#L428

causes the warning

warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling]

because xdg_data_home + ... creates a temporary std::string which is destroyed at the end of the line, and text then points into that destroyed string.

@yvt yvt added bug some feature is broken easy-fix labels Aug 17, 2019
dtomlinson-ga added a commit to dtomlinson-ga/openspades that referenced this issue Nov 27, 2019
Create c-string to store filepath before concatenating with output message.
yvt pushed a commit that referenced this issue Nov 29, 2019
* Fix use after free in Main.cpp (issue #846)

Create c-string to store filepath before concatenating with output message.

* Fix use after free in Main.cpp

Changed variable type to std::string and moved c_str() call

* Fix use after free in Main.cpp

Removed reference to directory variable
Conticop pushed a commit to Conticop/OpenSpades that referenced this issue Dec 23, 2019
* Fix use after free in Main.cpp (issue yvt#846)

Create c-string to store filepath before concatenating with output message.

* Fix use after free in Main.cpp

Changed variable type to std::string and moved c_str() call

* Fix use after free in Main.cpp

Removed reference to directory variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug some feature is broken easy-fix
Projects
None yet
Development

No branches or pull requests

2 participants