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.
This commit is contained in:
Brian Paul 2010-05-24 16:20:30 -06:00
parent 8cbc1517c1
commit e5d0c730d1
1 changed files with 7 additions and 1 deletions

View File

@ -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);