mesa: add out of bounds assertions for accessing texture matrix stack
authorBrian Paul <brianp@vmware.com>
Wed, 3 Feb 2010 19:25:28 +0000 (12:25 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 3 Feb 2010 22:48:41 +0000 (15:48 -0700)
src/mesa/main/texstate.c

index 2b26f651a54ce15fdb18f5af3b15d3b059b36021..6f8831dfe0357f3e01581baef8e7611840ba437b 100644 (file)
@@ -356,6 +356,7 @@ update_texture_matrices( GLcontext *ctx )
    ctx->Texture._TexMatEnabled = 0x0;
 
    for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
+      ASSERT(u < Elements(ctx->TextureMatrixStack));
       if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) {
         _math_matrix_analyse( ctx->TextureMatrixStack[u].Top );
 
@@ -627,6 +628,7 @@ update_texture_state( GLcontext *ctx )
         ctx->Texture._GenFlags |= texUnit->_GenFlags;
       }
 
+      ASSERT(unit < Elements(ctx->TextureMatrixStack));
       if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY)
         ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
    }