gallium: fix an edgeflags crash
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 24 Apr 2008 22:40:08 +0000 (16:40 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 24 Apr 2008 22:40:08 +0000 (16:40 -0600)
src/mesa/state_tracker/st_draw.c

index 097166f4446af98a01f047027a72525d9e8f7b00..e40eeddff55ee272969f18b4902479b1a2893e03 100644 (file)
@@ -208,10 +208,14 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
         ctx->Polygon.BackMode != GL_FILL)) {
       /* need edge flags */
       GLuint i;
-      unsigned *vec = (unsigned *) calloc(sizeof(unsigned), (count + 31) / 32);
+      unsigned *vec;
       struct st_buffer_object *stobj = st_buffer_object(array->BufferObj);
       ubyte *map;
 
+      if (!stobj)
+         return NULL;
+
+      vec = (unsigned *) calloc(sizeof(unsigned), (count + 31) / 32);
       if (!vec)
          return NULL;