config: fix a possible crash in the monitor config parser (#9460)
* Less crash-prone monitor config parser * clang-format
This commit is contained in:
parent
2e81648980
commit
e59464629f
1 changed files with 9 additions and 4 deletions
|
|
@ -1946,11 +1946,16 @@ std::optional<std::string> CConfigManager::handleMonitor(const std::string& comm
|
||||||
error += "invalid resolution ";
|
error += "invalid resolution ";
|
||||||
newrule.resolution = Vector2D();
|
newrule.resolution = Vector2D();
|
||||||
} else {
|
} else {
|
||||||
newrule.resolution.x = stoi(ARGS[1].substr(0, ARGS[1].find_first_of('x')));
|
try {
|
||||||
newrule.resolution.y = stoi(ARGS[1].substr(ARGS[1].find_first_of('x') + 1, ARGS[1].find_first_of('@')));
|
newrule.resolution.x = stoi(ARGS[1].substr(0, ARGS[1].find_first_of('x')));
|
||||||
|
newrule.resolution.y = stoi(ARGS[1].substr(ARGS[1].find_first_of('x') + 1, ARGS[1].find_first_of('@')));
|
||||||
|
|
||||||
if (ARGS[1].contains("@"))
|
if (ARGS[1].contains("@"))
|
||||||
newrule.refreshRate = stof(ARGS[1].substr(ARGS[1].find_first_of('@') + 1));
|
newrule.refreshRate = stof(ARGS[1].substr(ARGS[1].find_first_of('@') + 1));
|
||||||
|
} catch (...) {
|
||||||
|
error += "invalid resolution ";
|
||||||
|
newrule.resolution = Vector2D();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue