mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Removes some memory leaks
This commit is contained in:
parent
061ba0131a
commit
48704c27a9
@ -683,6 +683,12 @@ int Assay::processRequestBody() {
|
|||||||
std::string(a->m_key, 16, a->m_key.length() - 16) + ": " \
|
std::string(a->m_key, 16, a->m_key.length() - 16) + ": " \
|
||||||
+ a->m_value + "\n";
|
+ a->m_value + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (l.empty() == false) {
|
||||||
|
delete l.front();
|
||||||
|
l.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
fullRequest = fullRequest + "\n\n";
|
fullRequest = fullRequest + "\n\n";
|
||||||
fullRequest = fullRequest + m_requestBody.str();
|
fullRequest = fullRequest + m_requestBody.str();
|
||||||
m_collections.store("FULL_REQUEST", fullRequest);
|
m_collections.store("FULL_REQUEST", fullRequest);
|
||||||
|
@ -87,16 +87,18 @@ bool Pm::evaluate(Assay *assay, const std::string &input) {
|
|||||||
|
|
||||||
bool Pm::init(const std::string &file, const char **error) {
|
bool Pm::init(const std::string &file, const char **error) {
|
||||||
std::vector<std::string> vec;
|
std::vector<std::string> vec;
|
||||||
|
std::istringstream *iss;
|
||||||
|
|
||||||
replaceAll(param, "\\", "\\\\");
|
replaceAll(param, "\\", "\\\\");
|
||||||
|
|
||||||
char *content = parse_pm_content(param.c_str(), param.length(), error);
|
char *content = parse_pm_content(param.c_str(), param.length(), error);
|
||||||
if (content == NULL) {
|
if (content == NULL) {
|
||||||
return false;
|
iss = new std::istringstream(param);
|
||||||
|
} else {
|
||||||
|
iss = new std::istringstream(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istringstream iss(param);
|
std::copy(std::istream_iterator<std::string>(*iss),
|
||||||
std::copy(std::istream_iterator<std::string>(iss),
|
|
||||||
std::istream_iterator<std::string>(),
|
std::istream_iterator<std::string>(),
|
||||||
back_inserter(vec));
|
back_inserter(vec));
|
||||||
|
|
||||||
@ -106,6 +108,13 @@ bool Pm::init(const std::string &file, const char **error) {
|
|||||||
|
|
||||||
acmp_prepare(m_p);
|
acmp_prepare(m_p);
|
||||||
|
|
||||||
|
if (content) {
|
||||||
|
free(content);
|
||||||
|
content = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete iss;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ bool PmFromFile::init(const std::string &config, const char **error) {
|
|||||||
|
|
||||||
if (((std::ifstream *)iss)->is_open() == false) {
|
if (((std::ifstream *)iss)->is_open() == false) {
|
||||||
*error = std::string("Failed to open file: " + param).c_str();
|
*error = std::string("Failed to open file: " + param).c_str();
|
||||||
|
delete iss;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,6 +53,7 @@ bool PmFromFile::init(const std::string &config, const char **error) {
|
|||||||
|
|
||||||
acmp_prepare(m_p);
|
acmp_prepare(m_p);
|
||||||
|
|
||||||
|
delete iss;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,6 +420,7 @@ expression:
|
|||||||
if (phase != NULL) {
|
if (phase != NULL) {
|
||||||
definedPhase = phase->phase;
|
definedPhase = phase->phase;
|
||||||
secRuleDefinedPhase = phase->m_secRulesPhase;
|
secRuleDefinedPhase = phase->m_secRulesPhase;
|
||||||
|
delete phase;
|
||||||
} else if (a->action_kind == Action::RunTimeOnlyIfMatchKind ||
|
} else if (a->action_kind == Action::RunTimeOnlyIfMatchKind ||
|
||||||
a->action_kind == Action::RunTimeBeforeMatchAttemptKind) {
|
a->action_kind == Action::RunTimeBeforeMatchAttemptKind) {
|
||||||
None *none = dynamic_cast<None *>(a);
|
None *none = dynamic_cast<None *>(a);
|
||||||
@ -449,6 +450,8 @@ expression:
|
|||||||
for (Action *a : checkedActions) {
|
for (Action *a : checkedActions) {
|
||||||
driver.defaultActions[definedPhase].push_back(a);
|
driver.defaultActions[definedPhase].push_back(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete actions;
|
||||||
}
|
}
|
||||||
| CONFIG_DIR_SEC_MARKER
|
| CONFIG_DIR_SEC_MARKER
|
||||||
{
|
{
|
||||||
|
@ -290,6 +290,7 @@ bool Rule::evaluate(Assay *assay) {
|
|||||||
exclusions.push_back(y->m_key);
|
exclusions.push_back(y->m_key);
|
||||||
}
|
}
|
||||||
exclusions.push_back(variable->name);
|
exclusions.push_back(variable->name);
|
||||||
|
delete z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,6 +496,7 @@ bool Rule::evaluate(Assay *assay) {
|
|||||||
delete e->front();
|
delete e->front();
|
||||||
e->pop_front();
|
e->pop_front();
|
||||||
}
|
}
|
||||||
|
delete e;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,6 @@ std::vector<std::string> split(std::string str, char delimiter) {
|
|||||||
|
|
||||||
double random_number(const double from, const double to) {
|
double random_number(const double from, const double to) {
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
|
|
||||||
return std::bind(
|
return std::bind(
|
||||||
std::uniform_real_distribution<>{from, to},
|
std::uniform_real_distribution<>{from, to},
|
||||||
std::default_random_engine{ rd() })();
|
std::default_random_engine{ rd() })();
|
||||||
@ -1064,16 +1063,20 @@ std::string find_resource(const std::string& resource,
|
|||||||
iss = new std::ifstream(resource, std::ios::in);
|
iss = new std::ifstream(resource, std::ios::in);
|
||||||
if (iss->is_open()) {
|
if (iss->is_open()) {
|
||||||
iss->close();
|
iss->close();
|
||||||
|
delete iss;
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
delete iss;
|
||||||
|
|
||||||
// Trying the same path of the configuration file.
|
// Trying the same path of the configuration file.
|
||||||
std::string f = get_path(config) + "/" + resource;
|
std::string f = get_path(config) + "/" + resource;
|
||||||
iss = new std::ifstream(f, std::ios::in);
|
iss = new std::ifstream(f, std::ios::in);
|
||||||
if (iss->is_open()) {
|
if (iss->is_open()) {
|
||||||
iss->close();
|
iss->close();
|
||||||
|
delete iss;
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
delete iss;
|
||||||
|
|
||||||
return std::string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,12 @@ std::list<transaction::Variable *> *
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (reslIn->empty() == false) {
|
||||||
|
delete reslIn->front();
|
||||||
|
reslIn->pop_front();
|
||||||
|
}
|
||||||
|
delete reslIn;
|
||||||
|
|
||||||
std::string res = std::to_string(count);
|
std::string res = std::to_string(count);
|
||||||
|
|
||||||
reslOut->push_back(new transaction::Variable(std::string(var->name),
|
reslOut->push_back(new transaction::Variable(std::string(var->name),
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 37cf32eb8f939c06923a9ab24dd56a0975c36d4a
|
Subproject commit e16ceb6ed48dc5af3206220c3c8945def204b9b7
|
Loading…
x
Reference in New Issue
Block a user