mesa: Fix NULL deref in optimizer when NumInstructions == 0.
authorEric Anholt <eric@anholt.net>
Fri, 20 Nov 2009 20:42:06 +0000 (21:42 +0100)
committerEric Anholt <eric@anholt.net>
Fri, 20 Nov 2009 20:46:48 +0000 (21:46 +0100)
Bug #24984.

src/mesa/shader/prog_optimize.c

index 3d28d885a44f702cbbc8c08b9282e77ecc644c5f..4fe351251e8c8dca85334451d7d96b8610f674e2 100644 (file)
@@ -443,7 +443,7 @@ _mesa_remove_extra_move_use(struct gl_program *prog)
     *    FOO tmpY, arg0, arg1;
     */
 
-   for (i = 0; i < prog->NumInstructions - 1; i++) {
+   for (i = 0; i + 1 < prog->NumInstructions; i++) {
       const struct prog_instruction *mov = prog->Instructions + i;
 
       if (mov->Opcode != OPCODE_MOV ||