Added a sanity check on handle index in EntityToBCompatRef (bug 5539, r=psychonic).

This commit is contained in:
Kyle Sanderson 2012-12-01 13:41:00 -05:00
parent b7ac61cbea
commit 52aa0a5b27

View File

@ -975,6 +975,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));