summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/xlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/xlib')
-rw-r--r--src/mesa/pipe/xlib/xm_winsys.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c
index d737e984d1..506923784c 100644
--- a/src/mesa/pipe/xlib/xm_winsys.c
+++ b/src/mesa/pipe/xlib/xm_winsys.c
@@ -300,9 +300,12 @@ static void
xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
{
struct pipe_surface *surf = *s;
- if (surf->region)
- winsys->region_release(winsys, &surf->region);
- free(surf);
+ surf->refcount--;
+ if (surf->refcount == 0) {
+ if (surf->region)
+ winsys->region_release(winsys, &surf->region);
+ free(surf);
+ }
*s = NULL;
}