From: Vinson Lee Date: Sat, 4 Aug 2012 06:51:34 +0000 (-0700) Subject: mesa: Fix off-by-one error in Parse_TextureImageId. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=61b62c007a7941e9b45e83440e932160a597e0e1;p=mesa.git mesa: Fix off-by-one error in Parse_TextureImageId. Fixes out-of-bounds write defect reported by Coverity. Signed-off-by: Vinson Lee Reviewed-by: Brian Paul --- diff --git a/src/mesa/program/nvfragparse.c b/src/mesa/program/nvfragparse.c index bcc553a9bc6..20c8579b08b 100644 --- a/src/mesa/program/nvfragparse.c +++ b/src/mesa/program/nvfragparse.c @@ -582,7 +582,7 @@ Parse_TextureImageId(struct parse_state *parseState, RETURN_ERROR1("Expected TEX# source"); } unit = atoi((const char *) imageSrc + 3); - if ((unit < 0 || unit > MAX_TEXTURE_IMAGE_UNITS) || + if ((unit < 0 || unit >= MAX_TEXTURE_IMAGE_UNITS) || (unit == 0 && (imageSrc[3] != '0' || imageSrc[4] != 0))) { RETURN_ERROR1("Invalied TEX# source index"); }