fix(Core/Spells): Potential crashes in spell_generic and spell_item (#8810)

This commit is contained in:
Nefertumm
2021-11-09 07:10:03 -03:00
committed by GitHub
parent 12e92b5808
commit 4cad90be86
2 changed files with 61 additions and 13 deletions

View File

@@ -1993,7 +1993,10 @@ public:
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
eventInfo.GetActionTarget()->CastSpell((Unit*)nullptr, SPELL_FALL_DOWN, true, nullptr, aurEff);
if (eventInfo.GetActionTarget())
{
eventInfo.GetActionTarget()->CastSpell((Unit*)nullptr, SPELL_FALL_DOWN, true, nullptr, aurEff);
}
}
void Register() override
@@ -2674,7 +2677,10 @@ public:
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
if (GetHitUnit())
{
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
}
void Register() override
@@ -2719,7 +2725,10 @@ public:
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
if (GetHitUnit())
{
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
}
void Register() override
@@ -4601,6 +4610,11 @@ public:
Unit* caster = eventInfo.GetActionTarget();
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_GEN_BLADE_WARDING_TRIGGERED);
if (!caster)
{
return;
}
uint8 stacks = GetStackAmount();
int32 bp = 0;
@@ -4656,8 +4670,10 @@ public:
void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
// Final heal only on duration end
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_ENEMY_SPELL)
if (GetTargetApplication() && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_ENEMY_SPELL)
{
return;
}
// final heal
GetTarget()->CastSpell(GetTarget(), _spellId, true, nullptr, aurEff, GetCasterGUID());
@@ -5228,8 +5244,12 @@ public:
void HandleDummy(SpellEffIndex /* effIndex */)
{
if (Creature* vendor = GetCaster()->ToCreature())
if (vendor->GetEntry() == NPC_AMPHITHEATER_VENDOR)
{
if (vendor->GetEntry() == NPC_AMPHITHEATER_VENDOR && vendor->AI())
{
vendor->AI()->Talk(SAY_AMPHITHEATER_VENDOR);
}
}
}
void Register() override
@@ -5294,6 +5314,11 @@ public:
void RemoveVehicleAuras()
{
if (!GetHitUnit())
{
return;
}
Unit* u = nullptr;
if (Vehicle* vehicle = GetHitUnit()->GetVehicleKit())
{
@@ -5345,6 +5370,11 @@ public:
void EjectPassenger(SpellEffIndex /*effIndex*/)
{
if (!GetHitUnit())
{
return;
}
if (Vehicle* vehicle = GetHitUnit()->GetVehicleKit())
{
if (Unit* passenger = vehicle->GetPassenger(GetEffectValue() - 1))