src/mesa/shader/arbprogparse.c | 27 ++++++++++++++++++++++++--- 1 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 39988b5..cca9b0b 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -972,8 +972,8 @@ parse_texcoord_num (GLcontext * ctx, const GLubyte ** inst, { GLint i = parse_integer (inst, Program); - if ((i < 0) || (i >= (int)ctx->Const.MaxTextureUnits)) { - program_error(ctx, Program->Position, "Invalid texture unit index"); + if ((i < 0) || (i >= (int)ctx->Const.MaxTextureCoordUnits)) { + program_error(ctx, Program->Position, "Invalid texture coordinate index"); return 1; } @@ -981,6 +981,27 @@ parse_texcoord_num (GLcontext * ctx, const GLubyte ** inst, return 0; } + +/** + * \param coord The texture unit index + * \return 0 on sucess, 1 on error + */ +static GLuint +parse_teximage_num (GLcontext * ctx, const GLubyte ** inst, + struct arb_program *Program, GLuint * coord) +{ + GLint i = parse_integer (inst, Program); + + if ((i < 0) || (i >= (int)ctx->Const.MaxTextureImageUnits)) { + program_error(ctx, Program->Position, "Invalid texture image index"); + return 1; + } + + *coord = (GLuint) i; + return 0; +} + + /** * \param coord The weight index * \return 0 on sucess, 1 on error @@ -3003,7 +3024,7 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst, return 1; /* texImageUnit */ - if (parse_texcoord_num (ctx, inst, Program, &texcoord)) + if (parse_teximage_num (ctx, inst, Program, &texcoord)) return 1; fp->TexSrcUnit = texcoord;