[PATCH 02/11] mi: fix memory leak in miInitVisuals

Nicolas PENINGUY nico at lostgeeks.org
Fri Mar 25 16:26:32 PDT 2011


On Fri, 2011-03-25 at 20:41 +0200, Tiago Vignatti wrote:
> diff --git a/mi/micmap.c b/mi/micmap.c
> index 41e0300..7448ef8 100644
> --- a/mi/micmap.c
> +++ b/mi/micmap.c
> @@ -564,6 +564,8 @@ miInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp,
>  	{
>  	    vid = malloc(nvtype * sizeof (VisualID));
>  	    if (!vid) {
> +	        free(depth);
> +	        free(visual);
>  		free(preferredCVCs);
>  		return FALSE;
>  	    }

While I agree with this one, in fb/fbscreens.c there is

if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
	&defaultVisual,((unsigned long)1<<(imagebpp-1)), 8))
{
    free(visuals);
    free(depths);
    return FALSE;
}

(fbInitVisuals just calls miInitVisuals)

So I think this needs to be fixed to avoid double free.

Nicolas




More information about the xorg-devel mailing list