Skip to content

Commit

Permalink
Fix crash if std::unordered_map::at() did not find key in netvars. Ch…
Browse files Browse the repository at this point in the history
…eck first before calling at()
  • Loading branch information
gh-nomad committed Jan 13, 2025
1 parent e2d320d commit 3d7926e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions GHDumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,11 @@ namespace gh
for (auto& netvar : config["netvars"])
if (std::string(netvar["table"]) == table)
{
std::string netvarName = netvar["name"];
if (!netvars.count(netvarName)) // not present
continue;
std::stringstream address;
address << std::uppercase << std::hex << "0x" << netvars.at(std::string(netvar["name"]));
address << std::uppercase << std::hex << "0x" << netvars.at(netvarName);
tmp << FormatCheatEntry(std::string(netvar["name"]), {}, {}, {}, address.str(), "4 Bytes", 1);
}

Expand Down Expand Up @@ -770,7 +773,12 @@ namespace gh

for (auto& netvar : config["netvars"])
if (std::string(netvar["table"]) == table)
tableNetvars.push_back({netvar["name"],netvars.at(netvar["name"])});
{
std::string netvarName = netvar["name"];
if (!netvars.count(netvarName)) // not present
continue;
tableNetvars.push_back({netvarName, netvars.at(netvarName)});
}

std::sort(tableNetvars.begin(), tableNetvars.end(),
[](const std::pair<std::string,size_t>& a, const std::pair<std::string,size_t>& b) {
Expand Down

0 comments on commit 3d7926e

Please sign in to comment.