From f1db922c26477abddd0831422164357b99fc9971 Mon Sep 17 00:00:00 2001 From: Themaister Date: Wed, 28 May 2014 19:30:03 +0200 Subject: [PATCH] Add sanity check for Cg/GLSL attrib indices. --- gfx/shader_cg.c | 3 +++ gfx/shader_glsl.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/gfx/shader_cg.c b/gfx/shader_cg.c index 6b76079fab..cfe5ea4f37 100644 --- a/gfx/shader_cg.c +++ b/gfx/shader_cg.c @@ -149,6 +149,9 @@ static char cg_alias_define[GFX_MAX_SHADERS][128]; static void gl_cg_reset_attrib(void) { unsigned i; + // Add sanity check that we did not overflow. + rarch_assert(cg_attrib_index <= ARRAY_SIZE(cg_attribs)); + for (i = 0; i < cg_attrib_index; i++) cgGLDisableClientState(cg_attribs[i]); cg_attrib_index = 0; diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index a0bb9506c4..124d60c052 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -459,6 +459,9 @@ static bool compile_programs(GLuint *gl_prog) static void gl_glsl_reset_attrib(void) { unsigned i; + // Add sanity check that we did not overflow. + rarch_assert(gl_attrib_index <= ARRAY_SIZE(gl_attribs)); + for (i = 0; i < gl_attrib_index; i++) glDisableVertexAttribArray(gl_attribs[i]); gl_attrib_index = 0;