From 07d14c26814ef4d43841e1021646bcb75b4e29f1 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Mon, 3 Mar 2025 00:16:51 -0600 Subject: [PATCH] [Crash] Fix crash in add loot code path (#4745) --- zone/loot.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/zone/loot.cpp b/zone/loot.cpp index 8d412bfd6..9a61b3eb4 100644 --- a/zone/loot.cpp +++ b/zone/loot.cpp @@ -375,6 +375,10 @@ void NPC::AddLootDrop( if (item2->Slots & slots) { if (equipment[i]) { compitem = database.GetItem(equipment[i]); + if (!compitem) { + continue; + } + if (item2->AC > compitem->AC || (item2->AC == compitem->AC && item2->HP > compitem->HP)) { // item would be an upgrade // check if we're multi-slot, if yes then we have to keep @@ -385,6 +389,9 @@ void NPC::AddLootDrop( else { // Unequip old item auto *old_item = GetItem(i); + if (!old_item) { + continue; + } old_item->equip_slot = EQ::invslot::SLOT_INVALID; @@ -677,7 +684,7 @@ LootItem *NPC::GetItem(int slot_id) end = m_loot_items.end(); for (; cur != end; ++cur) { LootItem *item = *cur; - if (item->equip_slot == slot_id) { + if (item && item->equip_slot == slot_id) { return item; } }