st/mesa: new assertions to check array indexes
authorBrian Paul <brianp@vmware.com>
Fri, 9 Apr 2010 16:08:27 +0000 (10:08 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 9 Apr 2010 16:08:27 +0000 (10:08 -0600)
src/mesa/state_tracker/st_mesa_to_tgsi.c

index ad7a2b87ea88f9c54290f8e35227f4343bd46ab3..e8eb9ec3904157d224c4ecda8d9e78d5f39aa437 100644 (file)
@@ -181,6 +181,7 @@ src_register( struct st_translate *t,
       ASSERT(index >= 0);
       if (ureg_dst_is_undef(t->temps[index]))
          t->temps[index] = ureg_DECL_temporary( t->ureg );
+      assert(index < Elements(t->temps));
       return ureg_src(t->temps[index]);
 
    case PROGRAM_NAMED_PARAM:
@@ -197,9 +198,11 @@ src_register( struct st_translate *t,
          return t->constants[index];
 
    case PROGRAM_INPUT:
+      assert(t->inputMapping[index] < Elements(t->inputs));
       return t->inputs[t->inputMapping[index]];
 
    case PROGRAM_OUTPUT:
+      assert(t->outputMapping[index] < Elements(t->outputs));
       return ureg_src(t->outputs[t->outputMapping[index]]); /* not needed? */
 
    case PROGRAM_ADDRESS: