From 1fa641d7b6ba2ef21c552f83a1850f000dd1539c Mon Sep 17 00:00:00 2001 From: ariel- Date: Sat, 15 Apr 2017 14:58:21 -0300 Subject: Core/Scripts: fix dereferencing invalid iterator Closes #19464 --- src/server/scripts/Spells/spell_druid.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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 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(); } } -- cgit v1.2.3