From 1d7c709b522abb70771ade620b71de3333ba4898 Mon Sep 17 00:00:00 2001 From: qudzy <102037134+qudzy@users.noreply.github.com> Date: Wed, 1 Jun 2022 21:46:10 +0200 Subject: [PATCH] Prevent crash by guarding creatureData against nullptr --- src/strategy/Value.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/strategy/Value.cpp b/src/strategy/Value.cpp index 0d5f064f..a9067b31 100644 --- a/src/strategy/Value.cpp +++ b/src/strategy/Value.cpp @@ -53,8 +53,13 @@ CDPairCalculatedValue::CDPairCalculatedValue(PlayerbotAI* botAI, std::string con std::string const CDPairCalculatedValue::Format() { CreatureData const* creatureData = Calculate(); - CreatureTemplate const* bmTemplate = sObjectMgr->GetCreatureTemplate(creatureData->id1); - return bmTemplate ? bmTemplate->Name : ""; + if (creatureData) + { + CreatureTemplate const* bmTemplate = sObjectMgr->GetCreatureTemplate(creatureData->id1); + return bmTemplate ? bmTemplate->Name : ""; + } + + return ""; } CDPairListCalculatedValue::CDPairListCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) :