-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
In player.cpp, Player::getScore and Player::getHighScore return pointers to dealocated memory.
const char* Player::getHighscore()
{
std::string s = std::to_string(highscore);
s = "BEST: " + s;
return s.c_str();
}
const char* Player::getScore()
{
std::string s = std::to_string(score);
s = "DISTANCE: " + s;
return s.c_str();
}
When std::string s goes out of scope, the const char* that s.c_str returns is invalidated. Access to the underlying string may be garbage, cause a segfault, or cause other nasty issues.
Metadata
Metadata
Assignees
Labels
No labels