1
0
Fork 0
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:
Misa 2020-02-19 20:58:12 -08:00 committed by Ethan Lee
parent 0531ee9b19
commit ea8053303d

View file

@ -58,7 +58,7 @@ const char *GCChar(SDL_GameControllerButton button)
int ss_toi( std::string _s )
{
std::istringstream i(_s);
int x;
int x = 0;
i >> x;
return x;
}