From 8355efaca4b5997d5f5aa2d573d7b82819c87b53 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Sat, 1 Dec 2012 13:41:00 -0500 Subject: [PATCH] Added a sanity check on handle index in EntityToBCompatRef (bug 5539, r=psychonic). --- core/HalfLife2.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index b31bb392..52755131 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -993,6 +993,11 @@ cell_t CHalfLife2::EntityToBCompatRef(CBaseEntity *pEntity) IServerUnknown *pUnknown = (IServerUnknown *)pEntity; CBaseHandle hndl = pUnknown->GetRefEHandle(); + if (hndl == INVALID_EHANDLE_INDEX) + { + return INVALID_EHANDLE_INDEX; + } + if (hndl.GetEntryIndex() >= MAX_EDICTS) { return (hndl.ToInt() | (1<<31));