[Mesa-dev] [PATCH] xlib: fix memory leak on Display close
Alejandro PiƱeiro
apinheiro at igalia.com
Sat Apr 2 07:23:51 UTC 2016
On 02/04/16 00:04, John Sheu wrote:
> The XMesaVisual instances freed in the visuals table on display close
> are being freed with a free() call, instead of XMesaDestroyVisual(),
> causing a memory leak.
> ---
> src/mesa/drivers/x11/fakeglx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
> index 80b71765..2f4d9669 100644
> --- a/src/mesa/drivers/x11/fakeglx.c
> +++ b/src/mesa/drivers/x11/fakeglx.c
> @@ -794,7 +794,7 @@ destroy_visuals_on_display(Display *dpy)
> if (VisualTable[i]->display == dpy) {
> /* remove this visual */
> int j;
> - free(VisualTable[i]);
> + XMesaDestroyVisual(VisualTable[i]);
The change seems to make sense, but taking into account that the line of
code is somewhat old (2006), just out of curiosity: how did you find the
leak? Im curious to know why this was not detected before.
Additionally, it seems that this code was copied to
src/mesa/drivers/x11/xm_api.c and
src/gallium/state_trackers/glx/xlib/xm_api.c, and are using free instead
of XMesaDestroyVisual too, so they would be affected by the same leak.
Probably it would be good to fix all of them at the same time.
> for (j = i; j < NumVisuals - 1; j++)
> VisualTable[j] = VisualTable[j + 1];
> NumVisuals--;
More information about the mesa-dev
mailing list