summaryrefslogtreecommitdiff
path: root/src/config/ConfigManager.cpp
diff options
context:
space:
mode:
authorcyanbun96 <139242496+cyanbun96@users.noreply.github.com>2025-02-24 00:43:24 +0200
committerGitHub <noreply@github.com>2025-02-23 23:43:24 +0100
commite59464629fd1b0bdc4505786b8186d759933933c (patch)
treef26b25d47c430559c8db63fe78f6920cdcbc2027 /src/config/ConfigManager.cpp
parent2e81648980bf5dcaf96cbbc26aab5715599f2af3 (diff)
config: fix a possible crash in the monitor config parser (#9460)
* Less crash-prone monitor config parser * clang-format
Diffstat (limited to 'src/config/ConfigManager.cpp')
-rw-r--r--src/config/ConfigManager.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 9b547ffb..caa82871 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -1946,11 +1946,16 @@ std::optional<std::string> CConfigManager::handleMonitor(const std::string& comm
error += "invalid resolution ";
newrule.resolution = Vector2D();
} else {
- 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('@')));
+ try {
+ 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("@"))
- newrule.refreshRate = stof(ARGS[1].substr(ARGS[1].find_first_of('@') + 1));
+ if (ARGS[1].contains("@"))
+ newrule.refreshRate = stof(ARGS[1].substr(ARGS[1].find_first_of('@') + 1));
+ } catch (...) {
+ error += "invalid resolution ";
+ newrule.resolution = Vector2D();
+ }
}
}