From a545f1ab6d50e044c6e0b2d952af28e6d9059f80 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 May 2009 07:51:35 -0600 Subject: mesa: added some assertions --- src/mesa/main/enable.c | 2 ++ src/mesa/shader/arbprogram.c | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 2e7baa48ff..48268fcd27 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -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: diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index 21c5cfbf99..39136efada 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -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; } -- cgit v1.2.3