From fb6365ac689419a2e5dd758d4bf70c1a20ff41ff Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 20 Apr 2014 00:38:25 +0200 Subject: 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(). --- src/server/scripts/Outland/BlackTemple/boss_illidan.cpp | 2 +- src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp | 2 +- .../CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp | 3 ++- .../CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp | 2 +- .../scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/server/scripts/Outland') diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 957471216d8..b3d59c390c0 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -2074,7 +2074,7 @@ public: void UpdateAI(uint32 /*diff*/) OVERRIDE { - if (!UpdateVictim()) + if (!UpdateVictim() || !me->GetVictim()) return; if (me->EnsureVictim()->GetTypeId() != TYPEID_PLAYER) diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index d86d94088da..ed742a56ecd 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -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) diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp index 490bfaa16fc..3cb9ca26599 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp @@ -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; diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 73da4f62a23..4df431b91ac 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -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) diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp index 500bcd1ed8f..78a7d71732a 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp @@ -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(); } }; -- cgit v1.2.3