From c9f27d6f90a4413728727e668b7a4f7da9c4a737 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 3 Apr 2023 16:30:46 -0400 Subject: [PATCH] [Cleanup] Remove possible dereferenced nullptrs in bot.cpp (#3241) # Notes - Possible dereferenced nullptrs based on logic. --- zone/bot.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index e864642be..3c12288a2 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -4533,8 +4533,10 @@ bool Bot::Death(Mob *killerMob, int64 damage, uint16 spell_id, EQ::skills::Skill give_exp_client = give_exp->CastToClient(); bool IsLdonTreasure = (GetClass() == LDON_TREASURE); - if (entity_list.GetCorpseByID(GetID())) - entity_list.GetCorpseByID(GetID())->Depop(); + const auto c = entity_list.GetCorpseByID(GetID()); + if (c) { + c->Depop(); + } if (HasRaid()) { if (auto raid = entity_list.GetRaidByBotName(GetName()); raid) { @@ -6831,8 +6833,11 @@ Bot* Bot::GetBotByBotClientOwnerAndBotName(Client* c, const std::string& botName void Bot::ProcessBotGroupInvite(Client* c, std::string const& botName) { if (c && !c->HasRaid()) { Bot* invitedBot = GetBotByBotClientOwnerAndBotName(c, botName); + if (!invitedBot) { + return; + } - if (invitedBot && !invitedBot->HasGroup() && !invitedBot->HasRaid()) { + if (!invitedBot->HasGroup() && !invitedBot->HasRaid()) { if (!c->IsGrouped()) { auto g = new Group(c); if (AddBotToGroup(invitedBot, g)) {