From b2f71f16fc33438fc695455dfb7c0b2fa7b259f2 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Fri, 24 Jan 2025 02:10:06 -0600 Subject: [PATCH] [Memory Leak] Fix leak in NPC::RemoveItem (#4611) * [Memory Leak] Fix leak in NPC::RemoveItem * Update loot.cpp --- zone/loot.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zone/loot.cpp b/zone/loot.cpp index a330914e2..7fe2f8fb3 100644 --- a/zone/loot.cpp +++ b/zone/loot.cpp @@ -687,6 +687,7 @@ void NPC::RemoveItem(uint32 item_id, uint16 quantity, uint16 slot) LootItem *item = *cur; if (item->item_id == item_id && slot <= 0 && quantity <= 0) { m_loot_items.erase(cur); + safe_delete(item); UpdateEquipmentLight(); if (UpdateActiveLight()) { SendAppearancePacket(AppearanceType::Light, GetActiveLightType()); } return; @@ -694,6 +695,7 @@ void NPC::RemoveItem(uint32 item_id, uint16 quantity, uint16 slot) else if (item->item_id == item_id && item->equip_slot == slot && quantity >= 1) { if (item->charges <= quantity) { m_loot_items.erase(cur); + safe_delete(item); UpdateEquipmentLight(); if (UpdateActiveLight()) { SendAppearancePacket(AppearanceType::Light, GetActiveLightType()); } }