mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Removed unnecessary usage of heap-allocated VariableValue (m_var)
- Removed unused methods
This commit is contained in:
parent
dc0a06fc70
commit
6faf6d7ec0
@ -47,23 +47,11 @@ class AnchoredVariable {
|
|||||||
AnchoredVariable(const AnchoredVariable &a) = delete;
|
AnchoredVariable(const AnchoredVariable &a) = delete;
|
||||||
AnchoredVariable &operator= (const AnchoredVariable &a) = delete;
|
AnchoredVariable &operator= (const AnchoredVariable &a) = delete;
|
||||||
|
|
||||||
/*
|
~AnchoredVariable() = default;
|
||||||
: m_transaction(a.m_transaction),
|
|
||||||
m_offset(a.m_offset),
|
|
||||||
m_name(a.m_name),
|
|
||||||
m_value(a.m_value),
|
|
||||||
m_var(a.m_var) { }
|
|
||||||
*/
|
|
||||||
|
|
||||||
~AnchoredVariable();
|
|
||||||
|
|
||||||
void unset();
|
void unset();
|
||||||
void set(const std::string &a, size_t offset);
|
void set(const std::string &a, size_t offset);
|
||||||
void set(const std::string &a, size_t offset, size_t offsetLen);
|
void set(const std::string &a, size_t offset, size_t offsetLen);
|
||||||
void append(const std::string &a, size_t offset,
|
|
||||||
bool spaceSeparator = false);
|
|
||||||
void append(const std::string &a, size_t offset,
|
|
||||||
bool spaceSeparator, size_t size);
|
|
||||||
|
|
||||||
void evaluate(std::vector<const VariableValue *> *l);
|
void evaluate(std::vector<const VariableValue *> *l);
|
||||||
std::string * evaluate();
|
std::string * evaluate();
|
||||||
@ -75,7 +63,7 @@ class AnchoredVariable {
|
|||||||
std::string m_value;
|
std::string m_value;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VariableValue *m_var;
|
VariableValue m_var;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace modsecurity
|
} // namespace modsecurity
|
||||||
|
@ -31,19 +31,9 @@ AnchoredVariable::AnchoredVariable(Transaction *t,
|
|||||||
const std::string &name)
|
const std::string &name)
|
||||||
: m_transaction(t),
|
: m_transaction(t),
|
||||||
m_offset(0),
|
m_offset(0),
|
||||||
m_name(""),
|
m_name(name),
|
||||||
m_value(""),
|
m_value(""),
|
||||||
m_var(NULL) {
|
m_var(&name) {
|
||||||
m_name.append(name);
|
|
||||||
m_var = new VariableValue(&m_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AnchoredVariable::~AnchoredVariable() {
|
|
||||||
if (m_var) {
|
|
||||||
delete (m_var);
|
|
||||||
m_var = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,38 +46,14 @@ void AnchoredVariable::set(const std::string &a, size_t offset,
|
|||||||
size_t offsetLen) {
|
size_t offsetLen) {
|
||||||
m_offset = offset;
|
m_offset = offset;
|
||||||
m_value.assign(a.c_str(), a.size());
|
m_value.assign(a.c_str(), a.size());
|
||||||
m_var->addOrigin(offsetLen, offset);
|
m_var.addOrigin(offsetLen, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AnchoredVariable::set(const std::string &a, size_t offset) {
|
void AnchoredVariable::set(const std::string &a, size_t offset) {
|
||||||
m_offset = offset;
|
m_offset = offset;
|
||||||
m_value.assign(a.c_str(), a.size());
|
m_value.assign(a.c_str(), a.size());
|
||||||
m_var->addOrigin(m_value.size(), offset);
|
m_var.addOrigin(m_value.size(), offset);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AnchoredVariable::append(const std::string &a, size_t offset,
|
|
||||||
bool spaceSeparator) {
|
|
||||||
if (spaceSeparator && !m_value.empty()) {
|
|
||||||
m_value.append(" " + a);
|
|
||||||
} else {
|
|
||||||
m_value.append(a);
|
|
||||||
}
|
|
||||||
m_offset = offset;
|
|
||||||
m_var->addOrigin(a.size(), offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AnchoredVariable::append(const std::string &a, size_t offset,
|
|
||||||
bool spaceSeparator, size_t size) {
|
|
||||||
if (spaceSeparator && !m_value.empty()) {
|
|
||||||
m_value.append(" " + a);
|
|
||||||
} else {
|
|
||||||
m_value.append(a);
|
|
||||||
}
|
|
||||||
m_offset = offset;
|
|
||||||
m_var->addOrigin({size, offset});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,9 +62,8 @@ void AnchoredVariable::evaluate(std::vector<const VariableValue *> *l) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_var->setValue(m_value);
|
m_var.setValue(m_value);
|
||||||
VariableValue *m_var2 = new VariableValue(m_var);
|
l->push_back(new VariableValue(&m_var));
|
||||||
l->push_back(m_var2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -111,9 +76,7 @@ std::unique_ptr<std::string> AnchoredVariable::resolveFirst() {
|
|||||||
if (m_value.empty()) {
|
if (m_value.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
std::unique_ptr<std::string> a(new std::string());
|
return std::make_unique<std::string>(m_value);
|
||||||
a->append(m_value);
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user