summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-07 16:03:25 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-07 16:03:25 +0300
commite5de543efb891e6feb190a85103b1e53406e29c7 (patch)
tree1d15d4b79407ac131924608b796f9f7503c7a019
parent8eb9c7cb395aa1607161ec1805b2ceeaec0a6513 (diff)
downloadmanaplus-e5de543efb891e6feb190a85103b1e53406e29c7.tar.gz
manaplus-e5de543efb891e6feb190a85103b1e53406e29c7.tar.bz2
manaplus-e5de543efb891e6feb190a85103b1e53406e29c7.tar.xz
manaplus-e5de543efb891e6feb190a85103b1e53406e29c7.zip
fix leak in petdb with duplicate pets.
-rw-r--r--src/resources/db/petdb.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp
index aef1b2bda..0529ee874 100644
--- a/src/resources/db/petdb.cpp
+++ b/src/resources/db/petdb.cpp
@@ -80,15 +80,19 @@ void PETDB::loadXmlFile(const std::string &fileName)
continue;
}
- const int id = XML::getProperty(petNode, "id", 0);
- if (id == 0)
+ const int id = XML::getProperty(petNode, "id", -1);
+ if (id == -1)
{
logger->log("PET Database: PET with missing ID in %s!",
paths.getStringValue("petsFile").c_str());
continue;
}
- BeingInfo *const currentInfo = new BeingInfo;
+ BeingInfo *currentInfo = nullptr;
+ if (mPETInfos.find(id) != mPETInfos.end())
+ currentInfo = mPETInfos[id];
+ if (!currentInfo)
+ currentInfo = new BeingInfo;
currentInfo->setName(XML::langProperty(petNode,
// TRANSLATORS: unknown info name