[PATCH 01/11] xfree86: dri2: fix memory leak in DRI2AddDrawableRef

Michel Dänzer michel at daenzer.net
Sat Mar 26 01:01:57 PDT 2011


On Fre, 2011-03-25 at 20:41 +0200, Tiago Vignatti wrote: 
> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
>  hw/xfree86/dri2/dri2.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index 9ca378f..53f1e33 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -221,11 +221,15 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
>      if (ref == NULL)
>  	return BadAlloc;
>  	
> -    if (!AddResource(dri2_id, dri2DrawableRes, pPriv))
> +    if (!AddResource(dri2_id, dri2DrawableRes, pPriv)) {
> +        free(ref);
>  	return BadAlloc;
> +    }
>      if (!DRI2LookupDrawableRef(pPriv, id))
> -	if (!AddResource(id, dri2DrawableRes, pPriv))
> +	if (!AddResource(id, dri2DrawableRes, pPriv)) {
> +            free(ref);
>  	    return BadAlloc;

Indentation fail? (Looks to be an issue across the series)

Also, if the second AddResource call fails, the effects of the first one
should be reversed as well. But this is certainly an improvement even
without that.


-- 
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the xorg-devel mailing list