mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Removes some memory leaks
This commit is contained in:
@@ -87,16 +87,18 @@ bool Pm::evaluate(Assay *assay, const std::string &input) {
|
||||
|
||||
bool Pm::init(const std::string &file, const char **error) {
|
||||
std::vector<std::string> vec;
|
||||
std::istringstream *iss;
|
||||
|
||||
replaceAll(param, "\\", "\\\\");
|
||||
|
||||
char *content = parse_pm_content(param.c_str(), param.length(), error);
|
||||
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>(),
|
||||
back_inserter(vec));
|
||||
|
||||
@@ -106,6 +108,13 @@ bool Pm::init(const std::string &file, const char **error) {
|
||||
|
||||
acmp_prepare(m_p);
|
||||
|
||||
if (content) {
|
||||
free(content);
|
||||
content = NULL;
|
||||
}
|
||||
|
||||
delete iss;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -42,6 +42,7 @@ bool PmFromFile::init(const std::string &config, const char **error) {
|
||||
|
||||
if (((std::ifstream *)iss)->is_open() == false) {
|
||||
*error = std::string("Failed to open file: " + param).c_str();
|
||||
delete iss;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -52,6 +53,7 @@ bool PmFromFile::init(const std::string &config, const char **error) {
|
||||
|
||||
acmp_prepare(m_p);
|
||||
|
||||
delete iss;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user