From 05942467b37990f38fc80923f3d9ec63b160ad92 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 16 Oct 2014 18:21:50 +0300 Subject: Add missing checks. --- src/gui/windows/serverdialog.cpp | 11 ++++++++--- src/particle/particle.cpp | 16 ++++++++++++---- src/particle/particleemitter.cpp | 2 ++ src/resources/db/itemdb.cpp | 11 +++++++++-- 4 files changed, 31 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 30b4e600e..035a98a10 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -531,9 +531,14 @@ void ServerDialog::loadServers(const bool addNew) server.port = defaultPortForServerType(server.type); } } - else if ((xmlNameEqual(subNode, "description") - && server.description.empty()) || (!lang.empty() - && xmlNameEqual(subNode, description2.c_str()))) + else if (!subNode->xmlChildrenNode) + { + continue; + } + + if ((xmlNameEqual(subNode, "description") + && server.description.empty()) || (!lang.empty() + && xmlNameEqual(subNode, description2.c_str()))) { server.description = reinterpret_cast( subNode->xmlChildrenNode->content); diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index ed8db2d27..2ad4fe728 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -329,8 +329,12 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, // Image else if ((node = XML::findFirstChildByName(effectChildNode, "image"))) { - std::string imageSrc = reinterpret_cast( - node->xmlChildrenNode->content); + std::string imageSrc; + if (node->xmlChildrenNode) + { + imageSrc = reinterpret_cast( + node->xmlChildrenNode->content); + } if (!imageSrc.empty() && !dyePalettes.empty()) Dye::instantiate(imageSrc, dyePalettes); Image *const img = resman->getImage(imageSrc); @@ -375,8 +379,12 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, } else if (xmlNameEqual(emitterNode, "deatheffect")) { - const std::string deathEffect = reinterpret_cast( - emitterNode->xmlChildrenNode->content); + std::string deathEffect; + if (node->xmlChildrenNode) + { + deathEffect = reinterpret_cast( + emitterNode->xmlChildrenNode->content); + } char deathEffectConditions = 0x00; if (XML::getBoolProperty(emitterNode, "on-floor", true)) diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp index 496372a64..38462aeb6 100644 --- a/src/particle/particleemitter.cpp +++ b/src/particle/particleemitter.cpp @@ -322,6 +322,8 @@ ParticleEmitter::ParticleEmitter(const XmlNodePtrConst emitterNode, } else if (xmlNameEqual(propertyNode, "deatheffect")) { + if (!propertyNode->xmlChildrenNode) + continue; mDeathEffect = reinterpret_cast( propertyNode->xmlChildrenNode->content); mDeathEffectConditions = 0x00; diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index f4e4116ac..9d9550e82 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -431,8 +431,11 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum) } else if (xmlNameEqual(itemChild, "particlefx")) { - display.particles.push_back(reinterpret_cast( - itemChild->xmlChildrenNode->content)); + if (itemChild->xmlChildrenNode) + { + display.particles.push_back(reinterpret_cast( + itemChild->xmlChildrenNode->content)); + } } else if (xmlNameEqual(itemChild, "sound")) { @@ -745,6 +748,8 @@ static void loadSpriteRef(ItemInfo *const itemInfo, const XmlNodePtr node) static void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node) { + if (!node->xmlChildrenNode) + return; const std::string event = XML::getProperty(node, "event", ""); const std::string filename = reinterpret_cast( node->xmlChildrenNode->content); @@ -768,6 +773,8 @@ static void loadFloorSprite(SpriteDisplay *const display, { for_each_xml_child_node(spriteNode, floorNode) { + if (!spriteNode->xmlChildrenNode) + continue; if (xmlNameEqual(spriteNode, "sprite")) { SpriteReference *const currentSprite = new SpriteReference; -- cgit v1.2.3-70-g09d2