Skip to content

Commit

Permalink
Fix two rule-reload memory leak issues
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhsv committed Sep 15, 2022
1 parent 17f3bb0 commit e9a7ba4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
v3.x.y - YYYY-MMM-DD (to be released)
-------------------------------------

- Fix two rule-reload memory leak issues
[Issue #2801 - @Abce, @martinhsv]
- Correct whitespace handling for Include directive
[Issue #2800 - @877509395, @martinhsv]

Expand Down
2 changes: 2 additions & 0 deletions headers/modsecurity/rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class Rule {
return *this;
}

virtual ~Rule() {}

virtual bool evaluate(Transaction *transaction) = 0;

virtual bool evaluate(Transaction *transaction,
Expand Down
4 changes: 4 additions & 0 deletions src/rule_with_actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ RuleWithActions::RuleWithActions(
m_containsStaticBlockAction(false),
m_isChained(false) {

if (transformations != NULL) {
delete transformations;
}

if (actions) {
for (Action *a : *actions) {
if (a->action_kind == Action::ConfigurationKind) {
Expand Down
8 changes: 6 additions & 2 deletions test/cppcheck_suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ danglingTempReference:src/modsecurity.cc:206
knownConditionTrueFalse:src/operators/validate_url_encoding.cc:77
knownConditionTrueFalse:src/operators/verify_svnr.cc:87
rethrowNoCurrentException:headers/modsecurity/transaction.h:309
rethrowNoCurrentException:src/rule_with_actions.cc:123
ctunullpointer:src/rule_with_actions.cc:237
rethrowNoCurrentException:src/rule_with_actions.cc:127
ctunullpointer:src/rule_with_actions.cc:241
ctunullpointer:src/rule_with_operator.cc:135
ctunullpointer:src/rule_with_operator.cc:95
passedByValue:src/variables/global.h:109
Expand Down Expand Up @@ -93,6 +93,10 @@ functionStatic
variableScope
shadowFunction

constVariable
stlcstrConstructor
stlcstrStream
uselessCallsSubstr

// Examples
memleak:examples/reading_logs_via_rule_message/reading_logs_via_rule_message.h:147
Expand Down

0 comments on commit e9a7ba4

Please sign in to comment.