mesa: added some assertions
authorBrian Paul <brianp@vmware.com>
Fri, 22 May 2009 13:51:35 +0000 (07:51 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 22 May 2009 13:51:35 +0000 (07:51 -0600)
src/mesa/main/enable.c
src/mesa/shader/arbprogram.c

index 2e7baa4..48268fc 100644 (file)
@@ -119,6 +119,7 @@ client_state(GLcontext *ctx, GLenum cap, GLboolean state)
          CHECK_EXTENSION(NV_vertex_program, cap);
          {
             GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
+            ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib));
             var = &ctx->Array.ArrayObj->VertexAttrib[n].Enabled;
             flag = _NEW_ARRAY_ATTRIB(n);
          }
@@ -1316,6 +1317,7 @@ _mesa_IsEnabled( GLenum cap )
          CHECK_EXTENSION(NV_vertex_program);
          {
             GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
+            ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib));
             return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0);
          }
       case GL_MAP1_VERTEX_ATTRIB0_4_NV:
index 21c5cfb..39136ef 100644 (file)
@@ -254,6 +254,8 @@ _mesa_EnableVertexAttribArrayARB(GLuint index)
       return;
    }
 
+   ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
    FLUSH_VERTICES(ctx, _NEW_ARRAY);
    ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_TRUE;
    ctx->Array.ArrayObj->_Enabled |= _NEW_ARRAY_ATTRIB(index);
@@ -273,6 +275,8 @@ _mesa_DisableVertexAttribArrayARB(GLuint index)
       return;
    }
 
+   ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
    FLUSH_VERTICES(ctx, _NEW_ARRAY);
    ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_FALSE;
    ctx->Array.ArrayObj->_Enabled &= ~_NEW_ARRAY_ATTRIB(index);
@@ -315,6 +319,8 @@ _mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
       return;
    }
 
+   ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
    array = &ctx->Array.ArrayObj->VertexAttrib[index];
 
    switch (pname) {
@@ -387,6 +393,8 @@ _mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
       return;
    }
 
+   ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
    *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr;
 }