diff options
| author | Shauren <shauren.trinity@gmail.com> | 2023-01-19 14:12:08 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2023-01-19 14:12:08 +0100 |
| commit | 593721ff1fc7bb20fa2667625f5d3848a0786c73 (patch) | |
| tree | e6858b8f4d9466e4675ab21f8144e866f927dd3b /src/server/game/Entities/Unit | |
| parent | fe7fef7535513087291649e6fa03f231457542db (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/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 99222f018db..7e30092b6e6 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -4074,7 +4074,8 @@ void Unit::RemoveMovementImpairingAuras(bool withRoot) void Unit::RemoveAurasWithMechanic(uint32 mechanicMaskToRemove, AuraRemoveMode removeMode, uint32 exceptSpellId, bool withEffectMechanics) { - RemoveAppliedAuras([=](AuraApplication const* aurApp) + std::vector<Aura*> aurasToUpdateTargets; + RemoveAppliedAuras([=, &aurasToUpdateTargets](AuraApplication const* aurApp) { Aura* aura = aurApp->GetBase(); if (exceptSpellId && aura->GetId() == exceptSpellId) @@ -4089,9 +4090,12 @@ void Unit::RemoveAurasWithMechanic(uint32 mechanicMaskToRemove, AuraRemoveMode r return true; // effect mechanic matches required mask for removal - don't remove, only update targets - aura->UpdateTargetMap(aura->GetCaster()); + aurasToUpdateTargets.push_back(aura); return false; }, removeMode); + + for (Aura* aura : aurasToUpdateTargets) + aura->UpdateTargetMap(aura->GetCaster()); } void Unit::RemoveAurasByShapeShift() |
