fix: guard std::stoi/stof calls at input boundaries against exceptions

Wrap string-to-number conversions in try-catch where input comes from
external sources (realm address port, last_world.cfg, keybinding config,
ADT tile filenames) to prevent crashes on malformed data.
This commit is contained in:
Kelsi 2026-03-27 10:14:49 -07:00
parent ee20f823f7
commit ff77febb36
3 changed files with 23 additions and 11 deletions

View file

@ -192,10 +192,12 @@ void KeybindingManager::loadFromConfigFile(const std::string& filePath) {
key = ImGuiKey_End;
} else if (keyStr.find("F") == 0 && keyStr.length() <= 3) {
// F1-F12 keys
int fNum = std::stoi(keyStr.substr(1));
if (fNum >= 1 && fNum <= 12) {
key = static_cast<ImGuiKey>(ImGuiKey_F1 + (fNum - 1));
}
try {
int fNum = std::stoi(keyStr.substr(1));
if (fNum >= 1 && fNum <= 12) {
key = static_cast<ImGuiKey>(ImGuiKey_F1 + (fNum - 1));
}
} catch (...) {}
}
if (key == ImGuiKey_None) continue;