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

@@ -100,13 +100,9 @@ class AnchoredSetVariableTranslationProxy {
return nullptr;
}
std::unique_ptr<std::string> ret(new std::string(""));
auto ret = std::make_unique<std::string>(l[0]->getValue());
ret->assign(l.at(0)->getValue());
while (!l.empty()) {
auto &a = l.back();
l.pop_back();
for(auto a : l) {
delete a;
}

View File

@@ -41,9 +41,9 @@ namespace modsecurity {
class Rules {
public:
void dump() const {
for (int j = 0; j < m_rules.size(); j++) {
std::cout << " Rule ID: " << m_rules.at(j)->getReference();
std::cout << "--" << m_rules.at(j) << std::endl;
for (const auto &r : m_rules) {
std::cout << " Rule ID: " << r->getReference();
std::cout << "--" << r << std::endl;
}
}