diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-01-07 16:03:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-01-07 16:03:25 +0300 |
commit | e5de543efb891e6feb190a85103b1e53406e29c7 (patch) | |
tree | 1d15d4b79407ac131924608b796f9f7503c7a019 /src/resources | |
parent | 8eb9c7cb395aa1607161ec1805b2ceeaec0a6513 (diff) | |
download | manaplus-e5de543efb891e6feb190a85103b1e53406e29c7.tar.gz manaplus-e5de543efb891e6feb190a85103b1e53406e29c7.tar.bz2 manaplus-e5de543efb891e6feb190a85103b1e53406e29c7.tar.xz manaplus-e5de543efb891e6feb190a85103b1e53406e29c7.zip |
fix leak in petdb with duplicate pets.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/db/petdb.cpp | 10 |
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 |