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/particle/particle.cpp | 16 ++++++++++++---- src/particle/particleemitter.cpp | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src/particle') 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; -- cgit v1.2.3-60-g2f50