Skip to content

Commit

Permalink
MODIFIED: Using DecRef() instead of "delete this" in Spell::prepare()
Browse files Browse the repository at this point in the history
FIXED: Memory leaks in Spell::prepare()
==29704== 552 bytes in 1 blocks are definitely lost in loss record 356 of 429
==29704== at 0x4C28973: operator new(unsigned long) (vg_replace_malloc.c:261)
==29704== by 0x70082E: AIInterface::CastSpell(Unit*, SpellEntry*, SpellCastTargets) (AIInterface.cpp:3357)
==29704== by 0x6F8F56: AIInterface::_UpdateCombat(unsigned int) (AIInterface.cpp:1407)
  • Loading branch information
jackpoz committed Dec 16, 2010
1 parent 7931b0b commit 2e3ed30
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/arcemu-world/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ uint8 Spell::prepare( SpellCastTargets * targets )
if(!m_caster->IsInWorld())
{
sLog.outDebug("Object "I64FMT" is casting Spell ID %u while not in World", m_caster->GetGUID(), GetProto()->Id);
delete this;
DecRef();
return SPELL_FAILED_DONT_REPORT;
}

Expand All @@ -859,7 +859,10 @@ uint8 Spell::prepare( SpellCastTargets * targets )
{
AIInterface *ai = u_caster->GetAIInterface();
if (ai->getAIState() == STATE_FEAR || ai->getAIState() == STATE_WANDER)
{
DecRef();
return SPELL_FAILED_NOT_READY;
}
}

chaindamage = 0;
Expand Down Expand Up @@ -888,7 +891,10 @@ uint8 Spell::prepare( SpellCastTargets * targets )
{
// HookInterface events
if (!sHookInterface.OnCastSpell(p_caster, GetProto(), this))
{
DecRef();
return SPELL_FAILED_UNKNOWN;
}

if( p_caster->cannibalize )
{
Expand Down

0 comments on commit 2e3ed30

Please sign in to comment.