Moving the rules deletion to the RuleProperties class

The deletion was happning on the Rule class due to historical reasons.
The consequence of that was a parser memory leak.
This commit is contained in:
Felipe Zimmerle
2017-01-06 01:09:41 -03:00
committed by Felipe Zimmerle
parent 068a3eb517
commit a8e5cce744
5 changed files with 36 additions and 29 deletions

View File

@@ -94,7 +94,7 @@ Rule::Rule(std::string marker)
m_secmarker(true),
m_marker(marker),
m_maturity(0),
m_referenceCount(0),
m_referenceCount(1),
m_fileName(""),
m_lineNumber(0) { }
@@ -113,7 +113,7 @@ Rule::Rule(Operator *_op,
m_secmarker(false),
m_marker(""),
m_maturity(0),
m_referenceCount(0),
m_referenceCount(1),
m_fileName(fileName),
m_lineNumber(lineNumber) {
if (actions != NULL) {

View File

@@ -78,28 +78,8 @@ void Rules::decrementReferenceCount(void) {
Rules::~Rules() {
int i = 0;
free(unicode_map_table);
unicode_map_table = NULL;
/** Cleanup the rules */
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
std::vector<Rule *> rules = m_rules[i];
while (rules.empty() == false) {
Rule *rule = rules.back();
rule->refCountDecreaseAndCheck();
rules.pop_back();
}
}
for (i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
std::vector<actions::Action *> *tmp = &m_defaultActions[i];
while (tmp->empty() == false) {
actions::Action *a = tmp->back();
a->refCountDecreaseAndCheck();
tmp->pop_back();
}
}
}