fix(Core/Pet): Fix possible heap-use-after-free of charmInfo when handling pet action. (#21439)

This commit is contained in:
Anton Popovichenko 2025-02-14 20:02:02 +01:00 committed by GitHub
parent 75441ddb3b
commit cdcdf4564b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -432,8 +432,14 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
spell->prepare(&(spell->m_targets));
charmInfo->SetForcedSpell(0);
charmInfo->SetForcedTargetGUID();
// spell->prepare() can delete charm info.
// Let's refresh the pointer.
charmInfo = pet->GetCharmInfo();
if (charmInfo)
{
charmInfo->SetForcedSpell(0);
charmInfo->SetForcedTargetGUID();
}
}
else if (pet->ToPet() && (result == SPELL_FAILED_LINE_OF_SIGHT || result == SPELL_FAILED_OUT_OF_RANGE))
{