1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-03 03:23:33 +02: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
parent 0531ee9b19
commit a4c63eae24

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;
}