From 90dd61e668c1a048ceef4d17191819560d5c5ac3 Mon Sep 17 00:00:00 2001 From: Patrikkk Date: Sun, 21 Jun 2020 15:03:08 +0200 Subject: [PATCH] Moving the DisplayDollItemSync hook inside null check. In crafted (hacked) packet sending, people could send the DisplayDollItemSync packet with an entity ID that is not actually a display doll. This would not happen in a normal scenario. If they send the crafted packet, our hook would have been invoked and it would have contain a null TEDisplayDoll object since we tried to get the TileEntity object as a TEDisplayDoll object. --- TShockAPI/GetDataHandlers.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 08b851df..02fd32b0 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3797,11 +3797,10 @@ namespace TShockAPI if (oldItem.type == 0 && newItem.type == 0) return false; + + if (OnDisplayDollItemSync(args.Player, args.Data, playerIndex, tileEntityID, displayDoll, slot, isDye, oldItem, newItem)) + return true; } - - if (OnDisplayDollItemSync(args.Player, args.Data, playerIndex, tileEntityID, displayDoll, slot, isDye, oldItem, newItem)) - return true; - return false; }