[Glamor] [PATCH] Fix memory leak in _glamor_copy_n_to_n()

gongzg zhigang.gong at gmail.com
Thu Jan 16 08:08:21 PST 2014


LGTM, pushed, thanks.

On Wed, Jan 15, 2014 at 04:32:10PM +0900, Michel Dänzer wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
> 
> It would leak the memory allocated for the region rects in some cases.
> Found with valgrind.
> 
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
>  src/glamor_copyarea.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/glamor_copyarea.c b/src/glamor_copyarea.c
> index 4e6f953..bde6b4f 100644
> --- a/src/glamor_copyarea.c
> +++ b/src/glamor_copyarea.c
> @@ -427,7 +427,7 @@ _glamor_copy_n_to_n(DrawablePtr src,
>  		dispatch = glamor_get_dispatch(glamor_priv);
>  		if (!glamor_set_alu(dispatch, gc->alu)) {
>  			glamor_put_dispatch(glamor_priv);
> -			goto fail;
> +			goto fail_noregion;
>  		}
>  		glamor_put_dispatch(glamor_priv);
>  	}
> @@ -577,7 +577,6 @@ _glamor_copy_n_to_n(DrawablePtr src,
>  		if (n_dst_region == 0)
>  			ok = TRUE;
>  		free(clipped_dst_regions);
> -		RegionUninit(&region);
>  	} else {
>  		ok = __glamor_copy_n_to_n(src, dst, gc, box, nbox, dx, dy,
>  					  reverse, upsidedown, bitplane,
> @@ -585,6 +584,8 @@ _glamor_copy_n_to_n(DrawablePtr src,
>  	}
>  
>  fail:
> +	RegionUninit(&region);
> +fail_noregion:
>  	dispatch = glamor_get_dispatch(glamor_priv);
>  	glamor_set_alu(dispatch, GXcopy);
>  	glamor_put_dispatch(glamor_priv);
> -- 
> 1.8.5.2
> 
> 
> _______________________________________________
> Glamor mailing list
> Glamor at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/glamor


More information about the Glamor mailing list