mesa: don't call ctx->Driver.ClearBufferSubData() if size==0
authorBrian Paul <brianp@vmware.com>
Mon, 3 Mar 2014 16:59:45 +0000 (09:59 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 3 Mar 2014 17:41:42 +0000 (10:41 -0700)
Fixes failed assertion when trying to map zero-length region.

https://bugs.freedesktop.org/show_bug.cgi?id=75660
Cc: "10.0" "10.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/main/bufferobj.c

index 237b49cb1c7cc95b34c57a6be1d7568db20b1443..9ef55a784a1a232420bca90d0a961d3026c679ee 100644 (file)
@@ -1508,8 +1508,10 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
 
    if (data == NULL) {
       /* clear to zeros, per the spec */
-      ctx->Driver.ClearBufferSubData(ctx, offset, size,
-                                     NULL, 0, bufObj);
+      if (size > 0) {
+         ctx->Driver.ClearBufferSubData(ctx, offset, size,
+                                        NULL, 0, bufObj);
+      }
       return;
    }
 
@@ -1519,8 +1521,10 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
       return;
    }
 
-   ctx->Driver.ClearBufferSubData(ctx, offset, size,
-                                  clearValue, clearValueSize, bufObj);
+   if (size > 0) {
+      ctx->Driver.ClearBufferSubData(ctx, offset, size,
+                                     clearValue, clearValueSize, bufObj);
+   }
 }