Skip to content

Fix two rule-reload memory leak issues #2801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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