diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-01-07 14:32:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-01-07 14:32:55 +0300 |
commit | 09428bc03221484d27fe102ed436c08f6a09d866 (patch) | |
tree | ba6999fbfc471c0657dd0fa432ba2ed0c4dd7272 /src/resources/db/avatardb.cpp | |
parent | 108b71e515470b61aacdfc6f4be4339920322e7f (diff) | |
download | mv-09428bc03221484d27fe102ed436c08f6a09d866.tar.gz mv-09428bc03221484d27fe102ed436c08f6a09d866.tar.bz2 mv-09428bc03221484d27fe102ed436c08f6a09d866.tar.xz mv-09428bc03221484d27fe102ed436c08f6a09d866.zip |
fix leak in atatardb with duplicate avatars.
Diffstat (limited to 'src/resources/db/avatardb.cpp')
-rw-r--r-- | src/resources/db/avatardb.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/resources/db/avatardb.cpp b/src/resources/db/avatardb.cpp index a97059c2c..1df47e3ef 100644 --- a/src/resources/db/avatardb.cpp +++ b/src/resources/db/avatardb.cpp @@ -75,7 +75,12 @@ void AvatarDB::loadXmlFile(const std::string &fileName) if (!xmlNameEqual(avatarNode, "avatar")) continue; - BeingInfo *const currentInfo = new BeingInfo; + const int id = XML::getProperty(avatarNode, "id", 0); + BeingInfo *currentInfo = nullptr; + if (mAvatarInfos.find(id) != mAvatarInfos.end()) + currentInfo = mAvatarInfos[id]; + else + currentInfo = new BeingInfo; currentInfo->setName(XML::langProperty( // TRANSLATORS: unknown info name @@ -112,8 +117,7 @@ void AvatarDB::loadXmlFile(const std::string &fileName) } } currentInfo->setDisplay(display); - - mAvatarInfos[XML::getProperty(avatarNode, "id", 0)] = currentInfo; + mAvatarInfos[id] = currentInfo; } mLoaded = true; |