st/mesa: check for null before asserts, fix possible mem leak
authorBrian Paul <brianp@vmware.com>
Thu, 1 Oct 2009 20:49:34 +0000 (14:49 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 1 Oct 2009 20:49:39 +0000 (14:49 -0600)
src/mesa/state_tracker/st_cb_fbo.c

index fe0a1214933844c57be4aac9cb9407f5980897f0..e8399ded7bd1d3f8d7bbc837a5a13ad2c6cfeff4 100644 (file)
@@ -165,12 +165,12 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
                                                      strb->texture,
                                                      0, 0, 0,
                                                      surface_usage );
-
-      assert(strb->surface->texture);
-      assert(strb->surface->format);
-      assert(strb->surface->width == width);
-      assert(strb->surface->height == height);
-
+      if (strb->surface) {
+         assert(strb->surface->texture);
+         assert(strb->surface->format);
+         assert(strb->surface->width == width);
+         assert(strb->surface->height == height);
+      }
 
       return strb->surface != NULL;
    }
@@ -298,6 +298,7 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
    default:
       _mesa_problem(NULL,
                    "Unexpected format in st_new_renderbuffer_fb");
+      _mesa_free(strb);
       return NULL;
    }