aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2016-01-08 23:13:15 +0100
committerjackpoz <giacomopoz@gmail.com>2016-01-08 23:13:15 +0100
commitb1d0855624d1c83850fc36f5242437d7f7c1336b (patch)
tree3986f043d6ea4cd601d5786f4b842281593ec09f
parentad425f9f17502772289dd18ef6b74dc465556221 (diff)
Core/Spells: Fix static analysis issues and a crash
Fix confusing NULL checks in Raise Ally check cast. Fix a crash in Raise Ally triggered by executing ".cast back 61999" command targeting a pet in raid while being dead.
-rw-r--r--src/server/scripts/Spells/spell_dk.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp
index 193ec7cbb02..3cea620559a 100644
--- a/src/server/scripts/Spells/spell_dk.cpp
+++ b/src/server/scripts/Spells/spell_dk.cpp
@@ -1744,11 +1744,14 @@ public:
{
// Raise Ally cannot be casted on alive players
Unit* target = GetExplTargetUnit();
- if (target && target->IsAlive())
+ if (!target)
+ return SPELL_FAILED_NO_VALID_TARGETS;
+ if (target->IsAlive())
return SPELL_FAILED_TARGET_NOT_DEAD;
- else if (GetCaster()->ToPlayer()->InArena())
- return SPELL_FAILED_NOT_IN_ARENA;
- else if (target->IsGhouled())
+ if (Player* playerCaster = GetCaster()->ToPlayer())
+ if (playerCaster->InArena())
+ return SPELL_FAILED_NOT_IN_ARENA;
+ if (target->IsGhouled())
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
return SPELL_CAST_OK;