Skip to content

Commit 3d7926e

Browse files
committed
Fix crash if std::unordered_map::at() did not find key in netvars. Check first before calling at()
1 parent e2d320d commit 3d7926e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

GHDumper.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,11 @@ namespace gh
662662
for (auto& netvar : config["netvars"])
663663
if (std::string(netvar["table"]) == table)
664664
{
665+
std::string netvarName = netvar["name"];
666+
if (!netvars.count(netvarName)) // not present
667+
continue;
665668
std::stringstream address;
666-
address << std::uppercase << std::hex << "0x" << netvars.at(std::string(netvar["name"]));
669+
address << std::uppercase << std::hex << "0x" << netvars.at(netvarName);
667670
tmp << FormatCheatEntry(std::string(netvar["name"]), {}, {}, {}, address.str(), "4 Bytes", 1);
668671
}
669672

@@ -770,7 +773,12 @@ namespace gh
770773

771774
for (auto& netvar : config["netvars"])
772775
if (std::string(netvar["table"]) == table)
773-
tableNetvars.push_back({netvar["name"],netvars.at(netvar["name"])});
776+
{
777+
std::string netvarName = netvar["name"];
778+
if (!netvars.count(netvarName)) // not present
779+
continue;
780+
tableNetvars.push_back({netvarName, netvars.at(netvarName)});
781+
}
774782

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

0 commit comments

Comments
 (0)