aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellInfo.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-01-19 14:12:08 +0100
committerShauren <shauren.trinity@gmail.com>2023-01-19 14:12:08 +0100
commit593721ff1fc7bb20fa2667625f5d3848a0786c73 (patch)
treee6858b8f4d9466e4675ab21f8144e866f927dd3b /src/server/game/Spells/SpellInfo.cpp
parentfe7fef7535513087291649e6fa03f231457542db (diff)
Core/Auras: Fixed possible iterator invalidation crashes caused by calling UpdateTargetMap inside loops iterating m_appliedAuras
Closes #28609
Diffstat (limited to 'src/server/game/Spells/SpellInfo.cpp')
-rw-r--r--src/server/game/Spells/SpellInfo.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index cabad3bd6d2..b8fc1af8931 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -2861,15 +2861,19 @@ void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, uint8 effIndex, bool app
target->RemoveAurasWithMechanic(mechanicImmunity, AURA_REMOVE_BY_DEFAULT, Id);
else
{
- target->RemoveAppliedAuras([mechanicImmunity](AuraApplication const* aurApp)
+ std::vector<Aura*> aurasToUpdateTargets;
+ target->RemoveAppliedAuras([mechanicImmunity, &aurasToUpdateTargets](AuraApplication const* aurApp)
{
Aura* aura = aurApp->GetBase();
if (aura->GetSpellInfo()->GetAllEffectsMechanicMask() & mechanicImmunity)
- aura->UpdateTargetMap(aura->GetCaster());
+ aurasToUpdateTargets.push_back(aura);
// only update targets, don't remove anything
return false;
});
+
+ for (Aura* aura : aurasToUpdateTargets)
+ aura->UpdateTargetMap(aura->GetCaster());
}
}
}