aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-01-09 23:42:22 +0100
committerShauren <shauren.trinity@gmail.com>2021-05-17 00:05:47 +0200
commit7cd61b581cfdf3259685f72a4168b3f9aa102c5d (patch)
tree80afb43569329a7226b917dfcaef3e04854cc3d1 /src
parent4a65dcaecb103f62b9ee005e334de6a59d39368b (diff)
Core/Threat: fix a potential super edge case iterator invalidation
(cherry picked from commit 3dcd49ef9015582be304e2521e13052c68b917d6)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Combat/ThreatManager.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp
index d57c6abcb99..63606ddb307 100644
--- a/src/server/game/Combat/ThreatManager.cpp
+++ b/src/server/game/Combat/ThreatManager.cpp
@@ -342,7 +342,9 @@ void ThreatManager::AddThreat(Unit* target, float amount, SpellInfo const* spell
if (!redirInfo.empty())
{
float const origAmount = amount;
- for (auto const& pair : redirInfo) // (victim,pct)
+ // intentional copy - there's a nested AddThreat call further down that might cause AI calls which cast spells
+ auto const redirects = redirInfo;
+ for (auto const& pair : redirects) // (victim,pct)
{
Unit* redirTarget = nullptr;
auto it = _myThreatListEntries.find(pair.first); // try to look it up in our threat list first (faster)