Check whether the index is within bounds before accessing the array. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Brian Paul <brianp@vmware.com>tags/mesa-7.7-1
| @@ -91,7 +91,7 @@ static const GLubyte *tdfxDDGetString( GLcontext *ctx, GLenum name ) | |||
| else { | |||
| /* unexpected result: replace spaces with hyphens */ | |||
| int i; | |||
| for (i = 0; hardware[i] && (i < sizeof(hardware)); i++) { | |||
| for (i = 0; i < sizeof(hardware) && hardware[i]; i++) { | |||
| if (hardware[i] == ' ' || hardware[i] == '\t') { | |||
| hardware[i] = '-'; | |||
| } | |||
| @@ -642,7 +642,7 @@ Parse_SwizzleSuffix(const GLubyte *token, GLuint swizzle[4]) | |||
| else { | |||
| /* 4-component swizzle (vector) */ | |||
| GLint k; | |||
| for (k = 0; token[k] && k < 4; k++) { | |||
| for (k = 0; k < 4 && token[k]; k++) { | |||
| if (token[k] == 'x') | |||
| swizzle[k] = 0; | |||
| else if (token[k] == 'y') | |||
| @@ -578,7 +578,7 @@ _mesa_remove_extra_moves(struct gl_program *prog) | |||
| /* get pointer to previous instruction */ | |||
| prevI = i - 1; | |||
| while (removeInst[prevI] && prevI > 0) | |||
| while (prevI > 0 && removeInst[prevI]) | |||
| prevI--; | |||
| prevInst = prog->Instructions + prevI; | |||