From e62278859eb93d1ecadb30dd113a9f1e47fa3b07 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Fri, 9 Sep 2011 15:29:17 -0400 Subject: [PATCH] Validate ent index bounds in LookupEntity (bug 5080, r=fyren). --- core/HalfLife2.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index c4dd2283..664a888f 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -787,6 +787,12 @@ CBaseEntity *CHalfLife2::ReferenceToEntity(cell_t entRef) */ 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) { /* Attempt to use engine interface instead */