From 427e8be65624c9823667429ef2e6a395a1e8f113 Mon Sep 17 00:00:00 2001 From: Trazom62 Date: Mon, 31 May 2010 19:19:30 +0200 Subject: [PATCH] Fix Spell::m_selfContainer not reset in destructor. This should fix crash in Unit::FindCurrentSpellBySpellId. Fixes issue #2263. --HG-- branch : trunk --- src/game/Spell.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 4986a14324..11c77b8bc6 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -445,6 +445,14 @@ Spell::Spell(Unit* Caster, SpellEntry const *info, bool triggered, uint64 origin Spell::~Spell() { + if (m_referencedFromCurrentSpell && m_selfContainer && *m_selfContainer == this) + { + // Clean the reference to avoid later crash. + // If this error is repeating, we may have to add an assert to better track down how we get into this case. + sLog.outError("SPELL: deleting spell for spell ID %u. However, spell still referenced.", m_spellInfo->Id); + *m_selfContainer = NULL; + } + if (m_caster && m_caster->GetTypeId() == TYPEID_PLAYER) assert(m_caster->ToPlayer()->m_spellModTakingSpell != this); delete m_spellValue;