Skip to content

Commit

Permalink
Core/Spells: Fixed possible use after free with deleted focusObject (…
Browse files Browse the repository at this point in the history
…#30062)

* Core/Spells: Fixed possible use after free with deleted focusObject
  • Loading branch information
Jildor authored Jul 4, 2024
1 parent 8130024 commit 93ab97a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5426,7 +5426,9 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
if (m_spellInfo->RequiresSpellFocus)
{
focusObject = SearchSpellFocus();
if (!focusObject)
if (focusObject)
m_focusObjectGUID = focusObject->GetGUID();
else
return SPELL_FAILED_REQUIRES_SPELL_FOCUS;
}

Expand Down Expand Up @@ -7284,6 +7286,9 @@ bool Spell::UpdatePointers()
m_originalCaster = nullptr;
}

if (m_focusObjectGUID)
focusObject = ObjectAccessor::GetGameObject(*m_caster, m_focusObjectGUID);

if (m_castItemGUID && m_caster->GetTypeId() == TYPEID_PLAYER)
{
m_CastItem = m_caster->ToPlayer()->GetItemByGuid(m_castItemGUID);
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Spells/Spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ class TC_GAME_API Spell
DynObjAura* _dynObjAura;

// -------------------------------------------
ObjectGuid m_focusObjectGUID;
GameObject* focusObject;

// Damage and healing in effects need just calculate
Expand Down

0 comments on commit 93ab97a

Please sign in to comment.