Removes some memory leaks

This commit is contained in:
Felipe Zimmerle
2015-10-30 17:24:39 -03:00
parent 061ba0131a
commit 48704c27a9
8 changed files with 36 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -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;
}