mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
Core/Pet: Fixed possible crash after swapping pet with stable master. Closes #5177
This commit is contained in:
@@ -615,7 +615,7 @@ void WorldSession::HandleStablePet(WorldPacket & recv_data)
|
||||
Pet* pet = _player->GetPet();
|
||||
|
||||
// can't place in stable dead pet
|
||||
if (!pet||!pet->isAlive()||pet->getPetType() != HUNTER_PET)
|
||||
if (!pet || !pet->isAlive() || pet->getPetType() != HUNTER_PET)
|
||||
{
|
||||
SendStableResult(STABLE_ERR_STABLE);
|
||||
return;
|
||||
@@ -853,16 +853,22 @@ void WorldSession::HandleStableSwapPetCallback(PreparedQueryResult result, uint3
|
||||
return;
|
||||
}
|
||||
|
||||
// move alive pet to slot or delete dead pet
|
||||
Pet* pet = _player->GetPet();
|
||||
// The player's pet could have been removed during the delay of the DB callback
|
||||
if (!pet)
|
||||
{
|
||||
SendStableResult(STABLE_ERR_STABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
// move alive pet to slot or delete dead pet
|
||||
_player->RemovePet(pet, pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED);
|
||||
|
||||
// summon unstabled pet
|
||||
Pet* newpet = new Pet(_player);
|
||||
if (!newpet->LoadPetFromDB(_player, petEntry, petId))
|
||||
Pet* newPet = new Pet(_player);
|
||||
if (!newPet->LoadPetFromDB(_player, petEntry, petId))
|
||||
{
|
||||
delete newpet;
|
||||
delete newPet;
|
||||
SendStableResult(STABLE_ERR_STABLE);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user