mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-14 16:33:52 +00:00
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:
parent
ee20f823f7
commit
ff77febb36
3 changed files with 23 additions and 11 deletions
|
|
@ -6036,8 +6036,12 @@ bool Renderer::loadTestTerrain(pipeline::AssetManager* assetManager, const std::
|
|||
if (secondUnderscore != std::string::npos) {
|
||||
size_t dot = filename.find('.', secondUnderscore);
|
||||
if (dot != std::string::npos) {
|
||||
tileX = std::stoi(filename.substr(firstUnderscore + 1, secondUnderscore - firstUnderscore - 1));
|
||||
tileY = std::stoi(filename.substr(secondUnderscore + 1, dot - secondUnderscore - 1));
|
||||
try {
|
||||
tileX = std::stoi(filename.substr(firstUnderscore + 1, secondUnderscore - firstUnderscore - 1));
|
||||
tileY = std::stoi(filename.substr(secondUnderscore + 1, dot - secondUnderscore - 1));
|
||||
} catch (...) {
|
||||
LOG_WARNING("Failed to parse tile coords from: ", filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue