From 6051d0c4f8f5161cfe6b63ee3e12f24b4378915f Mon Sep 17 00:00:00 2001 From: StormBytePP Date: Thu, 20 Aug 2015 05:42:16 +0200 Subject: Core/Build: Fixed bitshift undefined behavior Coverity defect ID: 1193414 --- src/server/game/Spells/Auras/SpellAuraEffects.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 9ba7a62e215..f7491175a50 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -1278,8 +1278,14 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const for (Unit::AuraApplicationMap::iterator itr = tAuras.begin(); itr != tAuras.end();) { // Use the new aura to see on what stance the target will be - uint32 newStance = (1<<((newAura ? newAura->GetMiscValue() : 0)-1)); - + uint32 newStance = 0; + if (newAura) + { + if (newAura->GetMiscValue() > 0 && newAura->GetMiscValue() <= 32) //Not null and GetMiscValue is not == FORM_NONE + newStance = 1 << (newAura->GetMiscValue() - 1); + else + TC_LOG_ERROR("spell.aura", "newAura->GetMiscValue() returned value %i for SpellID: %u when it was expecting a value in range [0..31] for a bitshift", newAura->GetMiscValue(), newAura->GetId()); + } // If the stances are not compatible with the spell, remove it if (itr->second->GetBase()->IsRemovedOnShapeLost(target) && !(itr->second->GetBase()->GetSpellInfo()->Stances & newStance)) target->RemoveAura(itr); -- cgit v1.2.3