aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-04-15 14:58:21 -0300
committerariel- <ariel-@users.noreply.github.com>2017-04-15 15:00:15 -0300
commit1fa641d7b6ba2ef21c552f83a1850f000dd1539c (patch)
treeee558446f55d5ee0ed218314e671ec610df03dc9 /src
parentf7baf87b2d7a863f3c2ea48acdf7a62f55ac7729 (diff)
Core/Scripts: fix dereferencing invalid iterator
Closes #19464
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Spells/spell_druid.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp
index 812cc20a971..6e8b3130163 100644
--- a/src/server/scripts/Spells/spell_druid.cpp
+++ b/src/server/scripts/Spells/spell_druid.cpp
@@ -310,13 +310,16 @@ class spell_dru_enrage : public SpellScriptLoader
void RecalculateBaseArmor()
{
+ // Recalculate modifies the list while we're iterating through it, so let's copy it instead
Unit::AuraEffectList const& auras = GetTarget()->GetAuraEffectsByType(SPELL_AURA_MOD_BASE_RESISTANCE_PCT);
- for (Unit::AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i)
+ std::vector<AuraEffect*> aurEffs(auras.begin(), auras.end());
+
+ for (AuraEffect* aurEff : aurEffs)
{
- SpellInfo const* spellInfo = (*i)->GetSpellInfo();
+ SpellInfo const* spellInfo = aurEff->GetSpellInfo();
// Dire- / Bear Form (Passive)
if (spellInfo->SpellFamilyName == SPELLFAMILY_DRUID && spellInfo->SpellFamilyFlags.HasFlag(0x0, 0x0, 0x2))
- (*i)->RecalculateAmount();
+ aurEff->RecalculateAmount();
}
}