From fba3a2b67fe047100c54075307d5bb137125aad6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 4 Jan 2024 21:47:03 +0300 Subject: [PATCH] ref: soft: return NULL in GetEntityByIndex and ModelHandle --- ref/soft/r_local.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ref/soft/r_local.h b/ref/soft/r_local.h index cf90d978..e754434f 100644 --- a/ref/soft/r_local.h +++ b/ref/soft/r_local.h @@ -686,11 +686,17 @@ DECLARE_ENGINE_SHARED_CVAR_LIST() // 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]; }