Validate ent index bounds in LookupEntity (bug 5080, r=fyren).

This commit is contained in:
Nicholas Hastings 2011-09-09 15:29:17 -04:00
parent 51b91bce6d
commit e62278859e

View File

@ -787,6 +787,12 @@ CBaseEntity *CHalfLife2::ReferenceToEntity(cell_t entRef)
*/ */
CEntInfo *CHalfLife2::LookupEntity(int entIndex) CEntInfo *CHalfLife2::LookupEntity(int entIndex)
{ {
// Make sure that our index is within the bounds of the global ent array
if (entIndex < 0 || entIndex >= NUM_ENT_ENTRIES)
{
return NULL;
}
if (!g_EntList || entInfoOffset == -1) if (!g_EntList || entInfoOffset == -1)
{ {
/* Attempt to use engine interface instead */ /* Attempt to use engine interface instead */