dri/common: clear the loaderPrivate pointer in driDestroyDrawable
The GLX specification says about glXDestroyPixmap: "The storage for the GLX pixmap will be freed when it is not current to any client." We're not really following this language to the letter: some of the storage is freed immediately (in particular, the dri3_drawable, which contains both GLXDRIdrawable and loader_dri3_drawable). So we NULL out the pointers to that freed storage; the previous patches added the corresponding NULL-pointer checks. This fixes memory corruption in piglit ./bin/glx-visuals-depth/stencil -pixmap -auto Cc: 17.0 <mesa-stable@lists.freedesktop.org> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
@@ -645,6 +645,8 @@ driCreateNewDrawable(__DRIscreen *screen,
|
|||||||
{
|
{
|
||||||
__DRIdrawable *pdraw;
|
__DRIdrawable *pdraw;
|
||||||
|
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
pdraw = malloc(sizeof *pdraw);
|
pdraw = malloc(sizeof *pdraw);
|
||||||
if (!pdraw)
|
if (!pdraw)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -674,6 +676,16 @@ driCreateNewDrawable(__DRIscreen *screen,
|
|||||||
static void
|
static void
|
||||||
driDestroyDrawable(__DRIdrawable *pdp)
|
driDestroyDrawable(__DRIdrawable *pdp)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* The loader's data structures are going away, even if pdp itself stays
|
||||||
|
* around for the time being because it is currently bound. This happens
|
||||||
|
* when a currently bound GLX pixmap is destroyed.
|
||||||
|
*
|
||||||
|
* Clear out the pointer back into the loader's data structures to avoid
|
||||||
|
* accessing an outdated pointer.
|
||||||
|
*/
|
||||||
|
pdp->loaderPrivate = NULL;
|
||||||
|
|
||||||
dri_put_drawable(pdp);
|
dri_put_drawable(pdp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user