Core/Misc: Check GetVictim() for NULL before dereferencing it
Add additional NULL checks all around the code before dereferencing GetVictim() result. Keep in mind UpdateVictim() result has nothing to do with GetVictim() result and the caller shouldn't assume anything about GetVictim() based on UpdateVictim().
This commit is contained in:
1 parent
8ca6371793
commit
fb6365ac68
17 files changed
+37
-24
No files matched your search
@@ -151,7 +151,7 @@ void CasterAI::UpdateAI(uint32 diff)
|
||||
|
||||
events.Update(diff);
|
||||
|
||||
if (me->EnsureVictim()->HasBreakableByDamageCrowdControlAura(me))
|
||||
if (me->GetVictim() && me->EnsureVictim()->HasBreakableByDamageCrowdControlAura(me))
|
||||
{
|
||||
me->InterruptNonMeleeSpells(false);
|
||||
return;
|
||||
|
||||
@@ -391,7 +391,7 @@ public:
|
||||
if (me->HasUnitState(UNIT_STATE_STUNNED)) // While shifting to phase 2 malchezaar stuns himself
|
||||
return;
|
||||
|
||||
if (me->GetUInt64Value(UNIT_FIELD_TARGET) != me->EnsureVictim()->GetGUID())
|
||||
if (me->GetVictim() && me->GetUInt64Value(UNIT_FIELD_TARGET) != me->EnsureVictim()->GetGUID())
|
||||
me->SetTarget(me->EnsureVictim()->GetGUID());
|
||||
|
||||
if (phase == 1)
|
||||
|
||||
@@ -484,7 +484,7 @@ public:
|
||||
EnterEvadeMode();
|
||||
return;
|
||||
}
|
||||
else if (me->EnsureVictim()->GetTypeId() == TYPEID_PLAYER && me->EnsureVictim()->HealthBelowPct(10))
|
||||
else if (me->GetVictim() && me->EnsureVictim()->GetTypeId() == TYPEID_PLAYER && me->EnsureVictim()->HealthBelowPct(10))
|
||||
{
|
||||
me->EnsureVictim()->CastSpell(me->GetVictim(), 7267, true); // beg
|
||||
me->EnsureVictim()->RemoveGameObject(SPELL_DUEL_FLAG, true);
|
||||
@@ -832,7 +832,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (!UpdateVictim())
|
||||
if (!UpdateVictim() || !me->GetVictim())
|
||||
return;
|
||||
|
||||
//ScriptedAI::UpdateAI(diff);
|
||||
|
||||
@@ -298,7 +298,7 @@ public:
|
||||
Unit* target = (*itr)->getTarget();
|
||||
if (target
|
||||
&& target->GetTypeId() == TYPEID_PLAYER
|
||||
&& target->GetGUID() != me->EnsureVictim()->GetGUID()
|
||||
&& (!target->GetVictim() || target->GetGUID() != me->EnsureVictim()->GetGUID())
|
||||
&& target->GetPositionZ() > me->GetPositionZ() - 5
|
||||
&& !target->HasAura(AURA_SPECTRAL_EXHAUSTION))
|
||||
{
|
||||
|
||||
@@ -887,7 +887,8 @@ class boss_fenstalker : public CreatureScript
|
||||
if (volatileinf_timer <= diff)
|
||||
{
|
||||
// core bug
|
||||
me->EnsureVictim()->CastSpell(me->GetVictim(), SPELL_VOLATILE_INFECTION, false);
|
||||
if (me->GetVictim())
|
||||
me->EnsureVictim()->CastSpell(me->GetVictim(), SPELL_VOLATILE_INFECTION, false);
|
||||
volatileinf_timer = 12000;
|
||||
} else volatileinf_timer -= diff;
|
||||
|
||||
|
||||
@@ -428,7 +428,8 @@ class boss_zuljin : public CreatureScript
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
|
||||
{
|
||||
TankGUID = me->EnsureVictim()->GetGUID();
|
||||
if (me->GetVictim())
|
||||
TankGUID = me->EnsureVictim()->GetGUID();
|
||||
me->SetSpeed(MOVE_RUN, 5.0f);
|
||||
AttackStart(target); // change victim
|
||||
Claw_Rage_Timer = 0;
|
||||
|
||||
@@ -156,9 +156,12 @@ class boss_ayamiss : public CreatureScript
|
||||
_phase = PHASE_GROUND;
|
||||
SetCombatMovement(true);
|
||||
me->SetCanFly(false);
|
||||
Position VictimPos;
|
||||
me->EnsureVictim()->GetPosition(&VictimPos);
|
||||
me->GetMotionMaster()->MovePoint(POINT_GROUND, VictimPos);
|
||||
if (me->GetVictim())
|
||||
{
|
||||
Position VictimPos;
|
||||
me->EnsureVictim()->GetPosition(&VictimPos);
|
||||
me->GetMotionMaster()->MovePoint(POINT_GROUND, VictimPos);
|
||||
}
|
||||
DoResetThreat();
|
||||
events.ScheduleEvent(EVENT_LASH, urand(5000, 8000));
|
||||
events.ScheduleEvent(EVENT_TRASH, urand(3000, 6000));
|
||||
|
||||
@@ -272,7 +272,8 @@ class npc_glob_of_viscidus : public CreatureScript
|
||||
if (Viscidus->IsAlive() && Viscidus->GetHealthPct() < 5.0f)
|
||||
{
|
||||
Viscidus->SetVisible(true);
|
||||
Viscidus->EnsureVictim()->Kill(Viscidus);
|
||||
if (Viscidus->GetVictim())
|
||||
Viscidus->EnsureVictim()->Kill(Viscidus);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
{
|
||||
if (SendItemTimer <= diff)
|
||||
{
|
||||
if (me->EnsureVictim()->GetTypeId() == TYPEID_PLAYER)
|
||||
if (me->GetVictim() && me->EnsureVictim()->GetTypeId() == TYPEID_PLAYER)
|
||||
SendItem(me->GetVictim());
|
||||
SendItemTimer = 5000;
|
||||
} else SendItemTimer -= diff;
|
||||
|
||||
@@ -230,11 +230,14 @@ class boss_urom : public CreatureScript
|
||||
{
|
||||
if (arcaneExplosionTimer <= diff)
|
||||
{
|
||||
Position pos;
|
||||
me->EnsureVictim()->GetPosition(&pos);
|
||||
if (me->GetVictim())
|
||||
{
|
||||
Position pos;
|
||||
me->EnsureVictim()->GetPosition(&pos);
|
||||
|
||||
me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation());
|
||||
me->GetMotionMaster()->MoveChase(me->GetVictim());
|
||||
me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation());
|
||||
me->GetMotionMaster()->MoveChase(me->GetVictim());
|
||||
}
|
||||
me->SetWalk(true);
|
||||
|
||||
Talk(EMOTE_ARCANE_EXPLOSION);
|
||||
|
||||
@@ -199,7 +199,10 @@ class npc_flash_freeze : public CreatureScript
|
||||
|
||||
void UpdateAI(uint32 diff) OVERRIDE
|
||||
{
|
||||
if (!UpdateVictim() || me->EnsureVictim()->HasAura(SPELL_BLOCK_OF_ICE) || me->EnsureVictim()->HasAura(SPELL_FLASH_FREEZE_HELPER))
|
||||
if (!UpdateVictim()
|
||||
|| !me->GetVictim()
|
||||
|| me->EnsureVictim()->HasAura(SPELL_BLOCK_OF_ICE)
|
||||
|| me->EnsureVictim()->HasAura(SPELL_FLASH_FREEZE_HELPER))
|
||||
return;
|
||||
|
||||
if (me->EnsureVictim()->GetGUID() != targetGUID || instance->GetBossState(BOSS_HODIR) != IN_PROGRESS)
|
||||
|
||||
@@ -2074,7 +2074,7 @@ public:
|
||||
|
||||
void UpdateAI(uint32 /*diff*/) OVERRIDE
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
if (!UpdateVictim() || !me->GetVictim())
|
||||
return;
|
||||
|
||||
if (me->EnsureVictim()->GetTypeId() != TYPEID_PLAYER)
|
||||
|
||||
@@ -668,7 +668,7 @@ public:
|
||||
void UpdateAI(uint32 diff) OVERRIDE
|
||||
{
|
||||
//Return since we have no target
|
||||
if (!UpdateVictim())
|
||||
if (!UpdateVictim() || !me->GetVictim())
|
||||
return;
|
||||
|
||||
if (!CheckedAggro)
|
||||
|
||||
+2
-1
@@ -626,7 +626,8 @@ public:
|
||||
{
|
||||
DoCastVictim(SPELL_TIDAL_SURGE);
|
||||
// Hacky way to do it - won't trigger elseways
|
||||
me->EnsureVictim()->CastSpell(me->GetVictim(), SPELL_TIDAL_SURGE_FREEZE, true);
|
||||
if (me->GetVictim())
|
||||
me->EnsureVictim()->CastSpell(me->GetVictim(), SPELL_TIDAL_SURGE_FREEZE, true);
|
||||
TidalSurge_Timer = 15000+rand()%5000;
|
||||
} else TidalSurge_Timer -= diff;
|
||||
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public:
|
||||
void UpdateAI(uint32 diff) OVERRIDE
|
||||
{
|
||||
//Return since we have no target
|
||||
if (!UpdateVictim())
|
||||
if (!UpdateVictim() || !me->GetVictim())
|
||||
return;
|
||||
|
||||
if (me->EnsureVictim()->GetGUID() != victimGUID)
|
||||
|
||||
@@ -93,7 +93,7 @@ class npc_warp_splinter_treant : public CreatureScript
|
||||
|
||||
void UpdateAI(uint32 diff) OVERRIDE
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
if (!UpdateVictim() || !me->GetVictim())
|
||||
{
|
||||
if (WarpGuid && check_Timer <= diff)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ class npc_warp_splinter_treant : public CreatureScript
|
||||
return;
|
||||
}
|
||||
|
||||
if (me->EnsureVictim()->GetGUID() != WarpGuid)
|
||||
if (me->EnsureVictim()->GetGUID() != WarpGuid)
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -93,7 +93,7 @@ class npc_pet_hunter_snake_trap : public CreatureScript
|
||||
|
||||
void UpdateAI(uint32 diff) OVERRIDE
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
if (!UpdateVictim() || !me->GetVictim())
|
||||
return;
|
||||
|
||||
if (me->EnsureVictim()->HasBreakableByDamageCrowdControlAura(me))
|
||||
|
||||
Reference in new issue
Block a user