From 8eb9c7cb395aa1607161ec1805b2ceeaec0a6513 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 7 Jan 2014 14:51:36 +0300 Subject: fix leak in emotedb with duplicate emotes. --- src/resources/db/emotedb.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/resources/db/emotedb.cpp') diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp index 907bb75c4..7c710795f 100644 --- a/src/resources/db/emotedb.cpp +++ b/src/resources/db/emotedb.cpp @@ -100,8 +100,11 @@ void EmoteDB::loadXmlFile(const std::string &fileName) paths.getStringValue("emotesFile").c_str()); continue; } - - EmoteInfo *const currentInfo = new EmoteInfo; + EmoteInfo *currentInfo = nullptr; + if (mEmoteInfos.find(id) != mEmoteInfos.end()) + currentInfo = mEmoteInfos[id]; + else + currentInfo = new EmoteInfo; currentInfo->time = XML::getProperty(emoteNode, "time", 500); for_each_xml_child_node(spriteNode, emoteNode) @@ -169,7 +172,11 @@ void EmoteDB::loadSpecialXmlFile(const std::string &fileName) } const int altId = XML::getProperty(emoteNode, "altid", -1); - EmoteInfo *const currentInfo = new EmoteInfo; + EmoteInfo *currentInfo = nullptr; + if (mEmoteInfos.find(id) != mEmoteInfos.end()) + currentInfo = mEmoteInfos[id]; + if (!currentInfo) + currentInfo = new EmoteInfo; currentInfo->time = XML::getProperty(emoteNode, "time", 500); for_each_xml_child_node(spriteNode, emoteNode) -- cgit v1.2.3-60-g2f50