Buffer overflow fix (#1707)

This commit is contained in:
opsu 2023-03-05 20:16:42 +02:00 committed by GitHub
parent 7ce92f93ad
commit 0c8d1ba4a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -209,7 +209,7 @@ std::string removeBeginEndSpacesTabs(std::string str) {
}
int countAfter = 0;
while (str.length() != 0 && (str[str.length() - countAfter - 1] == ' ' || str[str.length() - 1 - countAfter] == '\t')) {
while ((int)str.length() - countAfter - 1 >= 0 && (str[str.length() - countAfter - 1] == ' ' || str[str.length() - 1 - countAfter] == '\t')) {
countAfter++;
}
@ -562,4 +562,4 @@ std::string replaceInString(std::string subject, const std::string& search, cons
pos += replace.length();
}
return subject;
}
}