In region_unmap(), check if region is mapped before decrementing refcount.
authorBrian <brian.paul@tungstengraphics.com>
Sat, 20 Oct 2007 21:45:24 +0000 (15:45 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Sat, 20 Oct 2007 21:45:24 +0000 (15:45 -0600)
src/mesa/pipe/i915simple/i915_regions.c
src/mesa/pipe/softpipe/sp_region.c

index cff90ab5dda8c20dd64ec5bbe309b2353e1182f5..577a6adfd8d6dbf6bc1028d375a2db71131cd420 100644 (file)
@@ -59,10 +59,13 @@ i915_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
 {
    struct i915_context *i915 = i915_context( pipe );
 
-   if (!--region->map_refcount) {
-      i915->pipe.winsys->buffer_unmap( i915->pipe.winsys,
-                                      region->buffer );
-      region->map = NULL;
+   if (region->map_refcount > 0) {
+      assert(region->map);
+      if (!--region->map_refcount) {
+         i915->pipe.winsys->buffer_unmap( i915->pipe.winsys,
+                                          region->buffer );
+         region->map = NULL;
+      }
    }
 }
 
index 0f4d2f05758c8d6c4eb23c358c445b939f17f360..4317a9ea1b86df3bd891b0bc2e347bff6963310b 100644 (file)
@@ -69,10 +69,13 @@ sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
 {
    struct softpipe_context *sp = softpipe_context( pipe );
 
-   if (!--region->map_refcount) {
-      sp->pipe.winsys->buffer_unmap( sp->pipe.winsys,
-                               region->buffer );
-      region->map = NULL;
+   if (region->map_refcount > 0) {
+      assert(region->map);
+      if (!--region->map_refcount) {
+         sp->pipe.winsys->buffer_unmap( sp->pipe.winsys,
+                                        region->buffer );
+         region->map = NULL;
+      }
    }
 }