diff --git a/headers/modsecurity/rules_properties.h b/headers/modsecurity/rules_properties.h index 9b0524e693..196bff3ff4 100644 --- a/headers/modsecurity/rules_properties.h +++ b/headers/modsecurity/rules_properties.h @@ -431,21 +431,24 @@ class RulesProperties { std::vector *to, std::ostringstream *err) { int amount_of_rules = 0; + // TODO: std::vector could be replaced with something more efficient. + std::vector v; for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) { std::vector *rules_to = to+i; - std::vector *rules_from = from+i; - // FIXME: std::vector could be replaced with something more efficient. - std::vector v; v.reserve(rules_to->size()); for (size_t z = 0; z < rules_to->size(); z++) { Rule *rule_ckc = rules_to->at(z); - if (rule_ckc->m_secMarker == false) { + if (rule_ckc->m_secMarker == true) { continue; } v.push_back(rule_ckc->m_ruleId); } - std::sort(v.begin(), v.end()); + } + std::sort (v.begin(), v.end()); + for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) { + std::vector *rules_from = from+i; + std::vector *rules_to = to+i; for (size_t j = 0; j < rules_from->size(); j++) { Rule *rule = rules_from->at(j); if (std::binary_search(v.begin(), v.end(), rule->m_ruleId)) { @@ -457,8 +460,8 @@ class RulesProperties { return -1; } amount_of_rules++; - rules_to->push_back(rule); rule->refCountIncrease(); + rules_to->push_back(rule); } } return amount_of_rules;