1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Prevent undefined behavior with integer under/overflow with help.Int()

It's possible that SDL_atoi() could call the libc atoi(), and if a
string is provided that's too large to fit into an integer, then that
would result in undefined behavior. To avoid this, use SDL_strtol()
instead.
This commit is contained in:
Misa 2020-09-27 13:41:07 -07:00 committed by Ethan Lee
parent 605b8a427c
commit 25f27d502a

View file

@ -106,7 +106,7 @@ int UtilityClass::Int(const char* str, int fallback /*= 0*/)
return fallback; return fallback;
} }
return SDL_atoi(str); return (int) SDL_strtol(str, NULL, 0);
} }
std::string UtilityClass::GCString(std::vector<SDL_GameControllerButton> buttons) std::string UtilityClass::GCString(std::vector<SDL_GameControllerButton> buttons)