Commit d125f685 authored by Micha Mueller's avatar Micha Mueller
Browse files

Fix possible memory leak

parent c317f466
...@@ -103,9 +103,11 @@ public: ...@@ -103,9 +103,11 @@ public:
auto ret = _templateSensorEntitys.insert(std::pair<std::string, SEntity*>(val.second.data(), entity)); auto ret = _templateSensorEntitys.insert(std::pair<std::string, SEntity*>(val.second.data(), entity));
if(!ret.second) { if(!ret.second) {
LOG(warning) << "Template " << _entityName << " " << val.second.data() << " already exists! Omitting..."; LOG(warning) << "Template " << _entityName << " " << val.second.data() << " already exists! Omitting...";
delete entity;
} }
} else { } else {
LOG(warning) << "Template " << _entityName << " \"" << val.second.data() << "\" has bad values! Ignoring..."; LOG(warning) << "Template " << _entityName << " \"" << val.second.data() << "\" has bad values! Ignoring...";
delete entity;
} }
} }
//template group //template group
...@@ -117,9 +119,11 @@ public: ...@@ -117,9 +119,11 @@ public:
auto ret = _templateSensorGroups.insert(std::pair<std::string, SGroup*>(val.second.data(), group)); auto ret = _templateSensorGroups.insert(std::pair<std::string, SGroup*>(val.second.data(), group));
if(!ret.second) { if(!ret.second) {
LOG(warning) << "Template " << _groupName << " " << val.second.data() << " already exists! Omitting..."; LOG(warning) << "Template " << _groupName << " " << val.second.data() << " already exists! Omitting...";
delete group;
} }
} else { } else {
LOG(warning) << "Template " << _groupName << " \"" << val.second.data() << "\" has bad values! Ignoring..."; LOG(warning) << "Template " << _groupName << " \"" << val.second.data() << "\" has bad values! Ignoring...";
delete group;
} }
} }
//entity //entity
...@@ -131,6 +135,7 @@ public: ...@@ -131,6 +135,7 @@ public:
_sensorEntitys.push_back(entity); _sensorEntitys.push_back(entity);
} else { } else {
LOG(warning) << _entityName << " \"" << val.second.data() << "\" has bad values! Ignoring..."; LOG(warning) << _entityName << " \"" << val.second.data() << "\" has bad values! Ignoring...";
delete entity;
} }
} }
//group //group
...@@ -142,6 +147,7 @@ public: ...@@ -142,6 +147,7 @@ public:
storeSensorGroup(group); storeSensorGroup(group);
} else { } else {
LOG(warning) << _groupName << " \"" << val.second.data() << "\" has bad values! Ignoring..."; LOG(warning) << _groupName << " \"" << val.second.data() << "\" has bad values! Ignoring...";
delete group;
} }
} }
} }
...@@ -287,6 +293,7 @@ protected: ...@@ -287,6 +293,7 @@ protected:
sGroup.pushBackSensor(sensor); sGroup.pushBackSensor(sensor);
} else { } else {
LOG(warning) << _baseName << " " << sGroup.getGroupName() << "::" << sensor->getName() << " could not be read! Omitting"; LOG(warning) << _baseName << " " << sGroup.getGroupName() << "::" << sensor->getName() << " could not be read! Omitting";
delete sensor;
} }
} }
} }
...@@ -344,12 +351,14 @@ protected: ...@@ -344,12 +351,14 @@ protected:
auto ret = _templateSensorGroups.insert(std::pair<std::string, SGroup*>(val.second.data(), group)); auto ret = _templateSensorGroups.insert(std::pair<std::string, SGroup*>(val.second.data(), group));
if(!ret.second) { if(!ret.second) {
LOG(warning) << "Template " << _groupName << " " << val.second.data() << " already exists! Omitting..."; LOG(warning) << "Template " << _groupName << " " << val.second.data() << " already exists! Omitting...";
delete group;
} }
} else { } else {
storeSensorGroup(group); storeSensorGroup(group);
} }
} else { } else {
LOG(warning) << _groupName << " " << group->getGroupName() << " could not be read! Omitting"; LOG(warning) << _groupName << " " << group->getGroupName() << " could not be read! Omitting";
delete group;
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment