workspace: fix integer overflow in selector parser (#5177)

This commit is contained in:
thejch 2024-03-19 19:33:39 -07:00 committed by GitHub
parent 8593c45be3
commit 95ac8a34b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -218,7 +218,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
const auto NEXTSPACE = selector.find_first_of(' ', i);
std::string prop = selector.substr(i, NEXTSPACE == std::string::npos ? std::string::npos : NEXTSPACE - i);
i = NEXTSPACE;
i = std::min(NEXTSPACE, std::string::npos - 1);
if (cur == 'r') {
int from = 0, to = 0;