From 59dc0bffc0f754de8daed29bce3a48e90ea6b4fb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 16 Mar 2011 14:28:45 +0200 Subject: Add checks and fix some code style. --- src/resources/emotedb.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/resources/emotedb.cpp') diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index 5b20742a8..6084f6092 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -76,6 +76,9 @@ void EmoteDB::load() for_each_xml_child_node(spriteNode, emoteNode) { + if (!spriteNode->xmlChildrenNode) + continue; + if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) { EmoteSprite *currentSprite = new EmoteSprite; @@ -128,6 +131,9 @@ void EmoteDB::load() for_each_xml_child_node(spriteNode, emoteNode) { + if (!spriteNode->xmlChildrenNode) + continue; + if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) { EmoteSprite *currentSprite = new EmoteSprite; @@ -160,13 +166,16 @@ void EmoteDB::unload() i != mEmoteInfos.end(); ++i) { - while (!i->second->sprites.empty()) + if (i->second) { - delete i->second->sprites.front()->sprite; - delete i->second->sprites.front(); - i->second->sprites.pop_front(); + while (!i->second->sprites.empty()) + { + delete i->second->sprites.front()->sprite; + delete i->second->sprites.front(); + i->second->sprites.pop_front(); + } + delete i->second; } - delete i->second; } mEmoteInfos.clear(); -- cgit v1.2.3-70-g09d2