util: check for null vertex buffer object in blit code
authorBrian Paul <brianp@vmware.com>
Thu, 10 Nov 2011 16:51:11 +0000 (09:51 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 11 Nov 2011 14:10:56 +0000 (07:10 -0700)
Don't crash if we fail to allocate a vertex buffer.

src/gallium/auxiliary/util/u_blit.c

index 6a4324bc2178dc256b479375e46c898d83120555..3a0d7d424060e5da849d6c7e18b52a87a5f9943c 100644 (file)
@@ -286,8 +286,10 @@ setup_vertex_data_tex(struct blit_state *ctx,
 
    offset = get_next_slot( ctx );
 
-   pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf,
-                               offset, sizeof(ctx->vertices), ctx->vertices);
+   if (ctx->vbuf) {
+      pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf,
+                                  offset, sizeof(ctx->vertices), ctx->vertices);
+   }
 
    return offset;
 }
@@ -599,10 +601,12 @@ util_blit_pixels_writemask(struct blit_state *ctx,
                                   s1, t1,
                                   z);
 
-   util_draw_vertex_buffer(ctx->pipe, ctx->cso, ctx->vbuf, offset,
-                           PIPE_PRIM_TRIANGLE_FAN,
-                           4,  /* verts */
-                           2); /* attribs/vert */
+   if (ctx->vbuf) {
+      util_draw_vertex_buffer(ctx->pipe, ctx->cso, ctx->vbuf, offset,
+                              PIPE_PRIM_TRIANGLE_FAN,
+                              4,  /* verts */
+                              2); /* attribs/vert */
+   }
 
    /* restore state we changed */
    cso_restore_blend(ctx->cso);