Replace usage of range-checked 'at' method when vector/string has already been size checked

This commit is contained in:
Eduardo Arias
2024-06-02 20:07:19 +00:00
parent 99ce9779e6
commit 0613ceeb75
11 changed files with 26 additions and 30 deletions

View File

@@ -405,7 +405,7 @@ int Transaction::processURI(const char *uri, const char *method,
std::string parsedURI = m_uri_decoded;
// The more popular case is without domain
if (!m_uri_decoded.empty() && m_uri_decoded.at(0) != '/') {
if (!m_uri_decoded.empty() && m_uri_decoded[0] != '/') {
bool fullDomain = true;
size_t scheme = m_uri_decoded.find(":")+1;
if (scheme == std::string::npos) {
@@ -540,7 +540,7 @@ int Transaction::addRequestHeader(const std::string& key,
}
// ltrim the key - following the modsec v2 way
while (ckey.empty() == false && isspace(ckey.at(0))) {
while (ckey.empty() == false && isspace(ckey[0])) {
ckey.erase(0, 1);
localOffset++;
}