Fix some memory leak from CreateTamedPetFrom.

This commit is contained in:
megamage
2011-11-28 14:10:56 -05:00
parent 529af3cd09
commit 81fea2d7b5
2 changed files with 7 additions and 0 deletions

View File

@@ -3828,7 +3828,10 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/)
Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget, m_spellInfo->Id);
if (!pet) // in very specific state like near world end/etc.
{
delete pet;
return;
}
// "kill" original creature
creatureTarget->DespawnOrUnsummon();
@@ -7014,7 +7017,10 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex)
uint32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue;
Pet* pet = unitTarget->CreateTamedPetFrom(creatureEntry, m_spellInfo->Id);
if (!pet)
{
delete pet;
return;
}
// add to world
pet->GetMap()->AddToMap(pet->ToCreature());

View File

@@ -1131,6 +1131,7 @@ public:
{
handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE, cInfo->Entry);
handler->SetSentErrorMessage (true);
delete pet;
return false;
}