config: fix crash when monitor position contains non-integer values before/after 'x' (#11573)

This commit is contained in:
Matteo Golinelli 2025-09-02 13:16:26 +02:00 committed by GitHub
parent 00423bb738
commit 78e86d879f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2196,8 +2196,14 @@ bool CMonitorRuleParser::parsePosition(const std::string& value, bool isFirst) {
m_rule.offset = Vector2D(-INT32_MAX, -INT32_MAX); m_rule.offset = Vector2D(-INT32_MAX, -INT32_MAX);
return false; return false;
} else { } else {
try {
m_rule.offset.x = stoi(value.substr(0, value.find_first_of('x'))); m_rule.offset.x = stoi(value.substr(0, value.find_first_of('x')));
m_rule.offset.y = stoi(value.substr(value.find_first_of('x') + 1)); m_rule.offset.y = stoi(value.substr(value.find_first_of('x') + 1));
} catch (...) {
m_error += "invalid offset ";
m_rule.offset = Vector2D(-INT32_MAX, -INT32_MAX);
return false;
}
} }
} }
return true; return true;