[PATCH 1/3] If AllocGrab() fails to set up grab, don't copy to a NULL grab

Peter Hutterer peter.hutterer at who-t.net
Mon Jan 6 19:50:29 PST 2014


On Mon, Jan 06, 2014 at 05:10:38PM -0800, Alan Coopersmith wrote:
> If either the initial calloc or the xi2mask_new fails, grab is NULL,
> but if a src grab is passed in, it was always being written to by
> CopyGrab (and if that failed, dereferenced again in teardown).
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

thanks, all three merged

Cheers,
   Peter

> ---
>  dix/grabs.c |   11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/dix/grabs.c b/dix/grabs.c
> index a03897a..7f4c871 100644
> --- a/dix/grabs.c
> +++ b/dix/grabs.c
> @@ -199,12 +199,11 @@ AllocGrab(const GrabPtr src)
>              free(grab);
>              grab = NULL;
>          }
> -    }
> -
> -    if (src && !CopyGrab(grab, src)) {
> -        free(grab->xi2mask);
> -        free(grab);
> -        grab = NULL;
> +        else if (src && !CopyGrab(grab, src)) {
> +            free(grab->xi2mask);
> +            free(grab);
> +            grab = NULL;
> +        }
>      }
>  
>      return grab;
> -- 
> 1.7.9.2
> 


More information about the xorg-devel mailing list