[Bug Fix] Handle memory leaks from return value of Client::GetTraderItems() (#2266)

* Move delete of ItemInstance to avoid edge case leaking in ZoneDatabase::LoadWorldContainer()

* Delete ItemInstance after use in Client::Handle_OP_AdventureMerchantPurchase()

* Delete ItemInstance after use in NPC::GetEquipmentMaterial()

* Delete ItemInstance after use in Bot::AddBotItem()

* Delete GetItems_Struct in edge case when !TradeItemsValid in Client::Handle_OP_Trader()

* Move delete GetItems_Struct to handle edge case when Customer is not valid in Client::Trader_EndTrader()
This commit is contained in:
Quintinon
2022-07-02 20:01:42 -07:00
committed by GitHub
parent 445c94bf4a
commit 30f35a920b
5 changed files with 8 additions and 2 deletions
+2
View File
@@ -4283,10 +4283,12 @@ void Bot::AddBotItem(
if (!database.botdb.SaveItemBySlot(this, slot_id, inst)) {
LogError("Failed to save item by slot to slot [{}] for [{}].", slot_id, GetCleanName());
safe_delete(inst);
return;
}
m_inv.PutItem(slot_id, *inst);
safe_delete(inst);
BotAddEquipItem(slot_id, item_id);
}