From d4fa3c441e38e9d285f6459a1046815b76c77911 Mon Sep 17 00:00:00 2001 From: dakrk Date: Sat, 3 Feb 2024 03:47:11 +0000 Subject: [PATCH] cheats: fix parsing cheat codes on some platforms using strtol here instead of strtoul when cheat code values are expected to be unsigned and are above 7fffffff breaks on platforms like Windows where long is 32-bit even on 64-bit platforms, capping out at 2147483647 and causing some cheat codes to break. --- core/cheats.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/cheats.cpp b/core/cheats.cpp index 541d84d6a..a14cd2641 100644 --- a/core/cheats.cpp +++ b/core/cheats.cpp @@ -677,7 +677,7 @@ static std::vector parseCodes(const std::string& s) curCode += c; if (curCode.length() == 8) { - codes.push_back(strtol(curCode.c_str(), nullptr, 16)); + codes.push_back(strtoul(curCode.c_str(), nullptr, 16)); curCode.clear(); } } @@ -688,7 +688,7 @@ static std::vector parseCodes(const std::string& s) { if (curCode.length() != 8) throw FlycastException("Invalid cheat code"); - codes.push_back(strtol(curCode.c_str(), nullptr, 16)); + codes.push_back(strtoul(curCode.c_str(), nullptr, 16)); } return codes;