From: Brian Date: Wed, 9 May 2007 14:04:32 +0000 (-0600) Subject: Check that texture units/samplers specified with glUniform1i() are legal. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3e4302fe3b3cf0d559b1288f3965f800ee35cd41;p=mesa.git Check that texture units/samplers specified with glUniform1i() are legal. --- diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 64f2a9fa126..3a54e68d0de 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0 * * Copyright (C) 2004-2007 Brian Paul All Rights Reserved. * @@ -1072,12 +1072,20 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count, * If we're setting a sampler, we must use glUniformi1()! */ if (shProg->Uniforms->Parameters[location].Type == PROGRAM_SAMPLER) { + GLint unit; if (type != GL_INT || count != 1) { _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(only glUniform1i can be used " "to set sampler uniforms)"); return; } + /* check that the sampler (tex unit index) is legal */ + unit = ((GLint *) values)[0]; + if (unit >= ctx->Const.MaxTextureImageUnits) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glUniform1(invalid sampler/tex unit index)"); + return; + } } if (count < 0) {