mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 14:46:24 +00:00
fix(Core/Pet): Fix possible crash when using dangling pointer as pets spell target and fix possible memory leak. (#21420)
This commit is contained in:
committed by
GitHub
parent
47c524581b
commit
fe2627bc91
@@ -47,7 +47,7 @@ Pet::Pet(Player* owner, PetType type) : Guardian(nullptr, owner ? owner->GetGUID
|
||||
m_auraRaidUpdateMask(0),
|
||||
m_loading(false),
|
||||
m_petRegenTimer(PET_FOCUS_REGEN_INTERVAL),
|
||||
m_tempspellTarget(nullptr),
|
||||
m_tempspellTarget(),
|
||||
m_tempoldTarget(),
|
||||
m_tempspellIsPositive(false),
|
||||
m_tempspell(0)
|
||||
@@ -716,9 +716,11 @@ void Pet::Update(uint32 diff)
|
||||
|
||||
if (m_tempspell)
|
||||
{
|
||||
Unit* tempspellTarget = m_tempspellTarget;
|
||||
Unit* tempoldTarget = nullptr;
|
||||
Unit* tempspellTarget = nullptr;
|
||||
if (!m_tempspellTarget.IsEmpty())
|
||||
tempspellTarget = ObjectAccessor::GetUnit(*this, m_tempspellTarget);
|
||||
|
||||
Unit* tempoldTarget = nullptr;
|
||||
if (!m_tempoldTarget.IsEmpty())
|
||||
tempoldTarget = ObjectAccessor::GetUnit(*this, m_tempoldTarget);
|
||||
|
||||
@@ -758,7 +760,7 @@ void Pet::Update(uint32 diff)
|
||||
|
||||
CastSpell(tempspellTarget, tempspell, false);
|
||||
m_tempspell = 0;
|
||||
m_tempspellTarget = nullptr;
|
||||
m_tempspellTarget = ObjectGuid::Empty;
|
||||
|
||||
if (tempspellIsPositive)
|
||||
{
|
||||
@@ -798,7 +800,7 @@ void Pet::Update(uint32 diff)
|
||||
else
|
||||
{
|
||||
m_tempspell = 0;
|
||||
m_tempspellTarget = nullptr;
|
||||
m_tempspellTarget = ObjectGuid::Empty;
|
||||
m_tempoldTarget = ObjectGuid::Empty;
|
||||
m_tempspellIsPositive = false;
|
||||
|
||||
@@ -2433,7 +2435,7 @@ void Pet::CastWhenWillAvailable(uint32 spellid, Unit* spellTarget, ObjectGuid ol
|
||||
if (!spellTarget)
|
||||
return;
|
||||
|
||||
m_tempspellTarget = spellTarget;
|
||||
m_tempspellTarget = spellTarget->GetGUID();
|
||||
m_tempspell = spellid;
|
||||
m_tempspellIsPositive = spellIsPositive;
|
||||
|
||||
@@ -2445,7 +2447,7 @@ void Pet::ClearCastWhenWillAvailable()
|
||||
{
|
||||
m_tempspellIsPositive = false;
|
||||
m_tempspell = 0;
|
||||
m_tempspellTarget = nullptr;
|
||||
m_tempspellTarget = ObjectGuid::Empty;
|
||||
m_tempoldTarget = ObjectGuid::Empty;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user