From 25f27d502a44476083dd56954465a1712294d5d6 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 27 Sep 2020 13:41:07 -0700 Subject: [PATCH] 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. --- desktop_version/src/UtilityClass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop_version/src/UtilityClass.cpp b/desktop_version/src/UtilityClass.cpp index 175cbaa5..4576f7ce 100644 --- a/desktop_version/src/UtilityClass.cpp +++ b/desktop_version/src/UtilityClass.cpp @@ -106,7 +106,7 @@ int UtilityClass::Int(const char* str, int fallback /*= 0*/) return fallback; } - return SDL_atoi(str); + return (int) SDL_strtol(str, NULL, 0); } std::string UtilityClass::GCString(std::vector buttons)