util: handle failed mapping in u_upload_alloc_buffer()
authorBrian Paul <brianp@vmware.com>
Mon, 24 Oct 2011 15:37:26 +0000 (09:37 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 24 Oct 2011 22:39:58 +0000 (16:39 -0600)
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/util/u_upload_mgr.c

index 9bcc1bb0c6b0e38dbb27e0dbb6dfbb749d3145a3..aef4d409c2cc67b0f662deb01f5c421e1f410491 100644 (file)
@@ -141,7 +141,12 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
                                        PIPE_TRANSFER_WRITE |
                                        PIPE_TRANSFER_FLUSH_EXPLICIT,
                                        &upload->transfer);
-   
+   if (upload->map == NULL) {
+      upload->size = 0;
+      pipe_resource_reference(&upload->buffer, NULL);
+      return PIPE_ERROR_OUT_OF_MEMORY;
+   }
+
    upload->size = size;
 
    upload->offset = 0;