mesa: Fix off-by-one error in Parse_TextureImageId.
authorVinson Lee <vlee@freedesktop.org>
Sat, 4 Aug 2012 06:51:34 +0000 (23:51 -0700)
committerVinson Lee <vlee@freedesktop.org>
Sun, 5 Aug 2012 04:42:23 +0000 (21:42 -0700)
Fixes out-of-bounds write defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/program/nvfragparse.c

index bcc553a9bc67af738007cb4ab0cc468437d504ca..20c8579b08bc8bfe9ee84385cb551375d77ea82e 100644 (file)
@@ -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");
    }