[PATCH libXi 5/7] XIGrabDevice: Unlock display in error path.

Peter Hutterer peter.hutterer at who-t.net
Sun Nov 2 21:20:03 PST 2014


On Sat, Nov 01, 2014 at 08:00:55PM +0200, Michal Srb wrote:
> Signed-off-by: Michal Srb <msrb at suse.com>
> ---
>  src/XIGrabDevice.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/src/XIGrabDevice.c b/src/XIGrabDevice.c
> index a8c5697..4ba91eb 100644
> --- a/src/XIGrabDevice.c
> +++ b/src/XIGrabDevice.c
> @@ -53,14 +53,21 @@ XIGrabDevice(Display* dpy, int deviceid, Window grab_window, Time time,
>  
>      if (mask->mask_len > INT_MAX - 3 ||
>          (mask->mask_len + 3)/4 >= 0xffff)
> +    {
> +        UnlockDisplay(dpy);
> +        SyncHandle();
>          return BadValue;
> +    }
>  
>      /* mask->mask_len is in bytes, but we need 4-byte units on the wire,
>       * and they need to be padded with 0 */
>      len = (mask->mask_len + 3)/4;
>      buff = calloc(4, len);
> -    if (!buff)
> +    if (!buff) {
> +        UnlockDisplay(dpy);
> +        SyncHandle();
>          return BadAlloc;
> +    }

I'd prefer the reply.status = <error>, goto out approach here.

Cheers,
   Peter

>  
>      GetReq(XIGrabDevice, req);
>      req->reqType  = extinfo->codes->major_opcode;
> -- 
> 1.8.4.5
> 
> _______________________________________________
> 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
> 


More information about the xorg-devel mailing list