mesa: fix display list regression (check if save->prim_count > 0 in vbo_save_EndList())
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 16 Sep 2008 19:23:01 +0000 (13:23 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 16 Sep 2008 19:23:01 +0000 (13:23 -0600)
src/mesa/vbo/vbo_save_api.c

index f93ef3a02a0c4413889e31140491e0a4f9e6a1fa..f69a33d817648c805646e21971e4cdb3773db4be 100644 (file)
@@ -1049,12 +1049,14 @@ void vbo_save_EndList( GLcontext *ctx )
    /* EndList called inside a (saved) Begin/End pair?
     */
    if (ctx->Driver.CurrentSavePrimitive != PRIM_OUTSIDE_BEGIN_END) {
-      GLint i = save->prim_count - 1;
 
-      ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
-      save->prim[i].end = 0;
-      save->prim[i].count = (save->vert_count - 
-                             save->prim[i].start);
+      if (save->prim_count > 0) {
+         GLint i = save->prim_count - 1;
+         ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
+         save->prim[i].end = 0;
+         save->prim[i].count = (save->vert_count - 
+                                save->prim[i].start);
+      }
 
       /* Make sure this vertex list gets replayed by the "loopback"
        * mechanism: