From 518a5e8ab1dfaa2510b6386b5e51e1f3da6e0803 Mon Sep 17 00:00:00 2001 From: Daerath Date: Sun, 21 Jan 2018 15:49:15 -0500 Subject: [PATCH] * Added test for null output of GetItem and log & return if the item cannot be found. --- zone/client_packet.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 57bd89465..3ee4d0038 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -11697,7 +11697,14 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app) } else { containers += StringFormat(" in (%u, %u) ", tsf->object_type, tsf->some_id); // container in inventory - combineObjectSlots = database.GetItem(tsf->some_id)->BagSlots; + auto item = database.GetItem(tsf->some_id); + if (!item) + { + Log(Logs::General, Logs::Error, "Invalid container ID: %d. GetItem returned null.\n", tsf->some_id); + return; + } + + combineObjectSlots = item->BagSlots; } std::string favoriteIDs; //gotta be big enough for 500 IDs @@ -11762,7 +11769,14 @@ void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app) else { // container in inventory snprintf(containers, 29, "in (%u,%u)", rss->object_type, rss->some_id); - combineObjectSlots = database.GetItem(rss->some_id)->BagSlots; + auto item = database.GetItem(rss->some_id); + if (!item) + { + Log(Logs::General, Logs::Error, "Invalid container ID: %d. GetItem returned null.\n", rss->some_id); + return; + } + + combineObjectSlots = item->BagSlots; } std::string searchClause;