From 4a6404874460937fe728c04e48eb9023e7476454 Mon Sep 17 00:00:00 2001 From: JJ <3617814+joligario@users.noreply.github.com> Date: Wed, 15 Feb 2023 21:55:15 -0500 Subject: [PATCH] [Crash] Fix crash issue with dropping items and order of operations (#2939) Should wait to null out invalid_drop until after it is used in log message. --- zone/inventory.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zone/inventory.cpp b/zone/inventory.cpp index e677b9407..ca3d2921d 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -848,13 +848,14 @@ void Client::DropItem(int16 slot_id, bool recurse) } } } - invalid_drop = nullptr; - + std::string message = fmt::format( "Tried to drop an item on the ground that was no-drop! item_name [{}] item_id ({})", invalid_drop->GetItem()->Name, invalid_drop->GetItem()->ID ); + + invalid_drop = nullptr; RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = message}); GetInv().DeleteItem(slot_id); return;