mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Minor changes related to std::shared_ptr usage in RuleWithActions
- RuleWithActions::evaluate(Transaction *transaction) - Removed temporary rm local variable used to immediately create std::shared_ptr<RuleMessage>. - Leverage std::make_shared & auto to simplify code.
This commit is contained in:
parent
10c6ee726f
commit
fef419f986
@ -172,9 +172,7 @@ RuleWithActions::~RuleWithActions() {
|
||||
|
||||
|
||||
bool RuleWithActions::evaluate(Transaction *transaction) {
|
||||
RuleMessage rm(this, transaction);
|
||||
std::shared_ptr<RuleMessage> rm2 = std::make_shared<RuleMessage>(&rm);
|
||||
return evaluate(transaction, rm2);
|
||||
return evaluate(transaction, std::make_shared<RuleMessage>(this, transaction));
|
||||
}
|
||||
|
||||
|
||||
@ -330,7 +328,7 @@ inline void RuleWithActions::executeTransformation(
|
||||
std::string newValue = a->evaluate(*oldValue, trans);
|
||||
|
||||
if (newValue != *oldValue) {
|
||||
std::shared_ptr<std::string> u(new std::string(newValue));
|
||||
auto u = std::make_shared<std::string>(newValue);
|
||||
if (m_containsMultiMatchAction) {
|
||||
ret->push_back(std::make_pair(u, a->m_name));
|
||||
(*nth)++;
|
||||
@ -355,14 +353,13 @@ void RuleWithActions::executeTransformations(
|
||||
int none = 0;
|
||||
int transformations = 0;
|
||||
std::string path("");
|
||||
std::shared_ptr<std::string> value =
|
||||
std::shared_ptr<std::string>(new std::string(in));
|
||||
auto value = std::make_shared<std::string>(in);
|
||||
|
||||
if (m_containsMultiMatchAction == true) {
|
||||
/* keep the original value */
|
||||
ret.push_back(std::make_pair(
|
||||
std::shared_ptr<std::string>(new std::string(*value)),
|
||||
std::shared_ptr<std::string>(new std::string(path))));
|
||||
std::make_shared<std::string>(*value),
|
||||
std::make_shared<std::string>(path)));
|
||||
}
|
||||
|
||||
for (Action *a : m_transformations) {
|
||||
@ -436,8 +433,8 @@ void RuleWithActions::executeTransformations(
|
||||
|
||||
if (!m_containsMultiMatchAction) {
|
||||
ret.push_back(std::make_pair(
|
||||
std::shared_ptr<std::string>(new std::string(*value)),
|
||||
std::shared_ptr<std::string>(new std::string(path))));
|
||||
std::make_shared<std::string>(*value),
|
||||
std::make_shared<std::string>(path)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user