From 7a02110a422fa13452242eb15e20b60fa9a92f52 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 17 Oct 2025 09:17:47 +0500 Subject: [PATCH] ref: gl: fix out of bounds access On GPUs where GL_ARB_shading_language_100 isn't available (i.e. all mobile GPUs I believe) this function would return total amount of texture units available. But ref_gl only tracks and uses MAX_TEXTURE_UNITS texture units, causing memory corruption in functions that doesn't check the limit. --- ref/gl/gl_local.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ref/gl/gl_local.h b/ref/gl/gl_local.h index 7b477d81..bb4ad5bc 100644 --- a/ref/gl/gl_local.h +++ b/ref/gl/gl_local.h @@ -764,7 +764,7 @@ static inline int GL_MaxTextureUnits( void ) { if( GL_Support( GL_SHADER_GLSL100_EXT )) return Q_min( Q_max( glConfig.max_texture_coords, glConfig.max_teximage_units ), MAX_TEXTURE_UNITS ); - return glConfig.max_texture_units; + return Q_min( glConfig.max_texture_units, MAX_TEXTURE_UNITS ); } #define WORLDMODEL (gp_cl->models[1])