From b946c8455dd136e719087912f67c6ca101e59e49 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 4 Jan 2024 21:46:41 +0300 Subject: [PATCH] ref: gl: return NULL in GetEntityByIndex and ModelHandle just in case --- ref/gl/gl_local.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ref/gl/gl_local.h b/ref/gl/gl_local.h index 8570bdbf..38c17be9 100644 --- a/ref/gl/gl_local.h +++ b/ref/gl/gl_local.h @@ -734,11 +734,17 @@ extern ref_host_t *gp_host; // static inline cl_entity_t *CL_GetEntityByIndex( int index ) { + if( unlikely( index < 0 || index >= tr.max_entities || !tr.entities )) + return NULL; + return &tr.entities[index]; } static inline model_t *CL_ModelHandle( int index ) { + if( unlikely( index < 0 || index >= gp_cl->nummodels )) + return NULL; + return gp_cl->models[index]; }