From 7bda44277218dabec1a5f89ef5497a43d5d2a3b3 Mon Sep 17 00:00:00 2001 From: Denneisk <20892685+Denneisk@users.noreply.github.com> Date: Mon, 13 Nov 2023 20:04:16 -0500 Subject: [PATCH] Mitigate nil addition in EGP.umsg.End --- .../gmod_wire_egp/lib/egplib/umsgsystem.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lua/entities/gmod_wire_egp/lib/egplib/umsgsystem.lua b/lua/entities/gmod_wire_egp/lib/egplib/umsgsystem.lua index 01c7989cd6..32ff5791d4 100644 --- a/lua/entities/gmod_wire_egp/lib/egplib/umsgsystem.lua +++ b/lua/entities/gmod_wire_egp/lib/egplib/umsgsystem.lua @@ -3,7 +3,7 @@ -------------------------------------------------------- local EGP = EGP -local CurSender +local CurSender = NULL local LastErrorTime = 0 --[[ Transmit Sizes: Angle = 12 @@ -21,7 +21,7 @@ local LastErrorTime = 0 EGP.umsg = {} function EGP.umsg.Start( name, sender ) - if CurSender then + if CurSender:IsValid() then if (LastErrorTime + 1 < CurTime()) then ErrorNoHalt("[EGP] Umsg error. It seems another umsg is already sending, but it occured over 1 second ago. Ending umsg.") EGP.umsg.End() @@ -40,10 +40,15 @@ function EGP.umsg.Start( name, sender ) end function EGP.umsg.End() - if CurSender then + if CurSender:IsValid() then if not EGP.IntervalCheck[CurSender] then EGP.IntervalCheck[CurSender] = { bytes = 0, time = 0 } end - EGP.IntervalCheck[CurSender].bytes = EGP.IntervalCheck[CurSender].bytes + net.BytesWritten() + local bytes = net.BytesWritten() + if bytes then + EGP.IntervalCheck[CurSender].bytes = EGP.IntervalCheck[CurSender].bytes + bytes + else + ErrorNoHalt("Tried to end EGP net message outside of net context?") + end end net.Broadcast() - CurSender = nil + CurSender = NULL end