mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
Fix some memory leak from CreateTamedPetFrom.
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -1131,6 +1131,7 @@ public:
|
||||
{
|
||||
handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE, cInfo->Entry);
|
||||
handler->SetSentErrorMessage (true);
|
||||
delete pet;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user