Skip to content

Commit 33a8d42

Browse files
authored
Script/Commands: Fix crash in .pet create command if Unit::CreateTamedPetFrom returns nullptr (#31218)
1 parent 760cd82 commit 33a8d42

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/server/scripts/Commands/cs_pet.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ class pet_commandscript : public CommandScript
9595

9696
// Everything looks OK, create new pet
9797
Pet* pet = player->CreateTamedPetFrom(creatureTarget);
98+
if (!pet)
99+
{
100+
handler->PSendSysMessage("CreateTamedPetFrom returned null.");
101+
handler->SetSentErrorMessage(true);
102+
return false;
103+
}
98104

99105
// "kill" original creature
100106
creatureTarget->DespawnOrUnsummon();

0 commit comments

Comments
 (0)