[PATCH 10/12] composite/xinerama: free newPix on error path.

Jamey Sharp jamey at minilop.net
Fri Oct 21 07:33:28 PDT 2011


This was a bit subtle. Usually if you free when AddResource fails, it's
a bug, so I had to read it a few times to realize that you're not
freeing pPixmap, but newPix. Some comment about that in the commit
message or in the code might be nice, but in any case:

Reviewed-by: Jamey Sharp <jamey at minilop.net>

On Thu, Oct 20, 2011 at 11:44:26AM +0100, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> newPix could be leaked if AddResource failed.
> 
> pointed out by coverity scan.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  composite/compext.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/composite/compext.c b/composite/compext.c
> index 722587a..01bd578 100644
> --- a/composite/compext.c
> +++ b/composite/compext.c
> @@ -725,8 +725,10 @@ PanoramiXCompositeNameWindowPixmap (ClientPtr client)
>  	}
>  
>  	if (!AddResource (newPix->info[i].id, RT_PIXMAP,
> -			  (pointer) pPixmap))
> +			  (pointer) pPixmap)) {
> +	    free (newPix);
>  	    return BadAlloc;
> +	}
>  
>  	++pPixmap->refcnt;
>      }
> -- 
> 1.7.6.4
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg-devel/attachments/20111021/b37fb2dd/attachment.pgp>


More information about the xorg-devel mailing list