summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo/vbo_exec_api.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-06-08 08:05:41 -0600
committerBrian Paul <[email protected]>2011-06-08 08:05:41 -0600
commitf1cdce95f606584a56eabf3b38eea19ff4c75757 (patch)
tree7ba16e0083afb7e0013c8208473a712f69a88e41 /src/mesa/vbo/vbo_exec_api.c
parenta25271fcb8d12298e64890cad25919938ae12018 (diff)
vbo: check array indexes to prevent negative indexing
See the piglit dlist-fdo31590.c test NOTE: This is a candidate for the 7.10 branch.
Diffstat (limited to 'src/mesa/vbo/vbo_exec_api.c')
-rw-r--r--src/mesa/vbo/vbo_exec_api.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 3c7c439b64c..2b8d38ef283 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -608,11 +608,15 @@ static void GLAPIENTRY vbo_exec_End( void )
if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- int idx = exec->vtx.vert_count;
- int i = exec->vtx.prim_count - 1;
- exec->vtx.prim[i].end = 1;
- exec->vtx.prim[i].count = idx - exec->vtx.prim[i].start;
+ if (exec->vtx.prim_count > 0) {
+ /* close off current primitive */
+ int idx = exec->vtx.vert_count;
+ int i = exec->vtx.prim_count - 1;
+
+ exec->vtx.prim[i].end = 1;
+ exec->vtx.prim[i].count = idx - exec->vtx.prim[i].start;
+ }
ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;