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

Michal Srb msrb at suse.com
Sat Nov 1 11:00:55 PDT 2014


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



More information about the xorg-devel mailing list