summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/sw
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-05-24 16:20:30 -0600
committerBrian Paul <brianp@vmware.com>2010-05-24 16:21:55 -0600
commite5d0c730d124aa5ed380ed29162ea76329898844 (patch)
tree585810dede2fb143c7dbbed1551ac36cb8447eed /src/gallium/winsys/sw
parent8cbc1517c1ba508dbf4d19f6eee729cdd1df8c37 (diff)
sw/xlib: NULL-out pointers after freeing image data
This fixes a double-free() error when not using a shared memory XImage. The XDestroyImage() function frees the ximage->data buffer if non-NULL. If we free it ourselves, we also need to NULL-out the pointer.
Diffstat (limited to 'src/gallium/winsys/sw')
-rw-r--r--src/gallium/winsys/sw/xlib/xlib_sw_winsys.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
index 56d2df825d..3d702ae08d 100644
--- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
+++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
@@ -255,11 +255,17 @@ xm_displaytarget_destroy(struct sw_winsys *ws,
}
else {
FREE(xm_dt->data);
+ if (xm_dt->tempImage->data == xm_dt->data) {
+ xm_dt->tempImage->data = NULL;
+ }
+ xm_dt->data = NULL;
}
}
- if (xm_dt->tempImage)
+ if (xm_dt->tempImage) {
XDestroyImage(xm_dt->tempImage);
+ xm_dt->tempImage = NULL;
+ }
if (xm_dt->gc)
XFreeGC(xm_dt->display, xm_dt->gc);