summaryrefslogtreecommitdiff
path: root/src/mesa/main/api_validate.c
diff options
context:
space:
mode:
authorZack Rusin <zackr@vmware.com>2010-03-15 15:24:38 -0400
committerZack Rusin <zackr@vmware.com>2010-03-15 15:24:38 -0400
commit275c4bd3643d773210780cb8d578ca84f2604684 (patch)
tree8266edc39d4253ac0f2a0ecd41f560f3d815bb5c /src/mesa/main/api_validate.c
parentc5c5cd7132e18f4aad8e73d8ee879f8823c4c1e7 (diff)
parentd0b35352ed27b1e66785c45ee95a352ed06b47ce (diff)
Merge remote branch 'origin/master' into gallium_draw_llvm
Diffstat (limited to 'src/mesa/main/api_validate.c')
-rw-r--r--src/mesa/main/api_validate.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 326ad6f909..4fb7b5ad61 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -123,6 +123,12 @@ check_valid_to_render(GLcontext *ctx, const char *function)
return GL_TRUE;
}
+
+/**
+ * Do bounds checking on array element indexes. Check that the vertices
+ * pointed to by the indices don't lie outside buffer object bounds.
+ * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds
+ */
static GLboolean
check_index_bounds(GLcontext *ctx, GLsizei count, GLenum type,
const GLvoid *indices, GLint basevertex)
@@ -147,17 +153,18 @@ check_index_bounds(GLcontext *ctx, GLsizei count, GLenum type,
vbo_get_minmax_index(ctx, &prim, &ib, &min, &max);
- if (min + basevertex < 0 ||
+ if ((int)(min + basevertex) < 0 ||
max + basevertex > ctx->Array.ArrayObj->_MaxElement) {
/* the max element is out of bounds of one or more enabled arrays */
- _mesa_warning(ctx, "glDrawElements() index=%u is "
- "out of bounds (max=%u)", max, ctx->Array.ArrayObj->_MaxElement);
+ _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)",
+ max, ctx->Array.ArrayObj->_MaxElement);
return GL_FALSE;
}
return GL_TRUE;
}
+
/**
* Error checking for glDrawElements(). Includes parameter checking
* and VBO bounds checking.