mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Initialize x to 0 in ss_toi()
This fixes a source of undefined behavior, where the int returned by ss_toi() would be random garbage memory if the string passed into it would be empty. That's because if the string is empty, there are no characters to parse, so nothing simply gets put into x. The easiest way to pass an empty string in to ss_toi() would be to use script commands with empty arguments.
This commit is contained in:
parent
0531ee9b19
commit
ea8053303d
1 changed files with 1 additions and 1 deletions
|
@ -58,7 +58,7 @@ const char *GCChar(SDL_GameControllerButton button)
|
||||||
int ss_toi( std::string _s )
|
int ss_toi( std::string _s )
|
||||||
{
|
{
|
||||||
std::istringstream i(_s);
|
std::istringstream i(_s);
|
||||||
int x;
|
int x = 0;
|
||||||
i >> x;
|
i >> x;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue