aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGildor <gildor55@gmail.com>2024-07-04 22:51:25 +0200
committerGitHub <noreply@github.com>2024-07-04 22:51:25 +0200
commit93ab97a37c769cfbc0c5d3aea44aee0e3cd877bc (patch)
tree299803e26330c8d899e41806f732983bc0502790
parent8130024497e370af3a2cbc0c633773386a66f2ef (diff)
Core/Spells: Fixed possible use after free with deleted focusObject (#30062)
* Core/Spells: Fixed possible use after free with deleted focusObject
-rw-r--r--src/server/game/Spells/Spell.cpp7
-rw-r--r--src/server/game/Spells/Spell.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index a78f031c310..a91768186a3 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -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;
}
@@ -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);
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 23b73deddeb..7abeb67b13c 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -530,6 +530,7 @@ class TC_GAME_API Spell
DynObjAura* _dynObjAura;
// -------------------------------------------
+ ObjectGuid m_focusObjectGUID;
GameObject* focusObject;
// Damage and healing in effects need just calculate