Skip to content

Commit

Permalink
cheats: fix parsing cheat codes on some platforms
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dakrk authored and flyinghead committed Feb 3, 2024
1 parent 6d69598 commit d4fa3c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ static std::vector<u32> 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();
}
}
Expand All @@ -688,7 +688,7 @@ static std::vector<u32> 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;
Expand Down

0 comments on commit d4fa3c4

Please sign in to comment.