Skip to content

Commit c785946

Browse files
committed
Pass RuleWithActions::executeTransformation arguments by reference
- This function already expects these arguments not to be null pointers, doesn't validate them and just dereference them. - In order to make this explicit and enforced by the compiler, they're now passed as references.
1 parent 47a9be8 commit c785946

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

headers/modsecurity/rule_with_actions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ class RuleWithActions : public Rule {
161161
const actions::transformations::Transformation &a,
162162
std::string &value,
163163
const Transaction *trans,
164-
TransformationResults *ret,
165-
std::string *path,
166-
int *nth) const;
164+
TransformationResults &ret,
165+
std::string &path,
166+
int &nth) const;
167167

168168
/* actions */
169169
actions::Action *m_disruptiveAction;

src/rule_with_actions.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -327,23 +327,23 @@ inline void RuleWithActions::executeTransformation(
327327
const actions::transformations::Transformation &a,
328328
std::string &value,
329329
const Transaction *trans,
330-
TransformationResults *ret,
331-
std::string *path,
332-
int *nth) const {
330+
TransformationResults &ret,
331+
std::string &path,
332+
int &nth) const {
333333

334334
if (a.transform(value, trans) && m_containsMultiMatchAction) {
335-
ret->push_back({value, a.m_name});
336-
(*nth)++;
335+
ret.push_back({value, a.m_name});
336+
nth++;
337337
}
338338

339-
if (path->empty()) {
340-
path->append(*a.m_name.get());
339+
if (path.empty()) {
340+
path.append(*a.m_name.get());
341341
} else {
342-
path->append("," + *a.m_name.get());
342+
path.append("," + *a.m_name.get());
343343
}
344344

345345
ms_dbg_a(trans, 9, " T (" + \
346-
std::to_string(*nth) + ") " + \
346+
std::to_string(nth) + ") " + \
347347
*a.m_name.get() + ": \"" + \
348348
utils::string::limitTo(80, value) +"\"");
349349
}
@@ -352,7 +352,7 @@ void RuleWithActions::executeTransformations(
352352
const Transaction *trans, const std::string &in, TransformationResults &ret) {
353353
int none = 0;
354354
int transformations = 0;
355-
std::string path("");
355+
std::string path;
356356
auto value = in;
357357

358358
if (m_containsMultiMatchAction == true) {
@@ -380,16 +380,16 @@ void RuleWithActions::executeTransformations(
380380
// FIXME: here the object needs to be a transformation already.
381381
auto t = dynamic_cast<const Transformation*>(a.get());
382382
assert(t != nullptr);
383-
executeTransformation(*t, value, trans, &ret, &path,
384-
&transformations);
383+
executeTransformation(*t, value, trans, ret, path,
384+
transformations);
385385
}
386386
}
387387

388388
for (const Transformation *a : m_transformations) {
389389
assert(a != nullptr);
390390
if (none == 0) {
391-
executeTransformation(*a, value, trans, &ret, &path,
392-
&transformations);
391+
executeTransformation(*a, value, trans, ret, path,
392+
transformations);
393393
}
394394
if (a->m_isNone) {
395395
none--;
@@ -418,8 +418,8 @@ void RuleWithActions::executeTransformations(
418418
auto a = dynamic_cast<const Transformation*>(b.second.get());
419419
assert(a != nullptr);
420420
if (none == 0) {
421-
executeTransformation(*a, value, trans, &ret, &path,
422-
&transformations);
421+
executeTransformation(*a, value, trans, ret, path,
422+
transformations);
423423
}
424424
if (a->m_isNone) {
425425
none--;

0 commit comments

Comments
 (0)