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 2f388cfdb4
commit 8355efaca4

View File

@ -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));