File U_XIChangeHierarchy-Add-missing-unlock.patch of Package libXi.928

From: Michal Srb <msrb@suse.com>
Date: Sat Nov 1 20:00:52 2014 +0200
Subject: [PATCH]XIChangeHierarchy: Add missing unlock.
Patch-mainline: Upstream
Git-commit: 83261c52a17543437882e2863b7f06a92c9039f8
Git-repo: git://anongit.freedesktop.org/git/xorg/lib/libXi
References: bnc#940529
Signed-off-by: Egbert Eich <eich@suse.com>

When num_changes <= 0 or Xmalloc fails, the display has to be unlocked.

Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
 src/XIHierarchy.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/XIHierarchy.c b/src/XIHierarchy.c
index 3d2b4f2..441fec0 100644
--- a/src/XIHierarchy.c
+++ b/src/XIHierarchy.c
@@ -49,14 +49,14 @@ XIChangeHierarchy(Display* dpy,
     xXIChangeHierarchyReq *req;
     XExtDisplayInfo *info = XInput_find_display(dpy);
     char *data = NULL, *dptr;
-    int dlen = 0, i;
+    int dlen = 0, i, ret = Success;
 
     LockDisplay(dpy);
     if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1)
 	return (NoSuchExtension);
 
     if (num_changes <= 0)
-        return Success;
+        goto out;
 
     GetReq(XIChangeHierarchy, req);
     req->reqType = info->codes->major_opcode;
@@ -91,8 +91,10 @@ XIChangeHierarchy(Display* dpy,
 
     req->length += dlen / 4; /* dlen is 4-byte aligned */
     data = Xmalloc(dlen);
-    if (!data)
-        return BadAlloc;
+    if (!data) {
+        ret = BadAlloc;
+        goto out;
+    }
 
     dptr = data;
     for (i = 0, any = changes; i < num_changes; i++, any++)
@@ -155,8 +157,10 @@ XIChangeHierarchy(Display* dpy,
     }
 
     Data(dpy, data, dlen);
+
+out:
     Xfree(data);
     UnlockDisplay(dpy);
     SyncHandle();
-    return Success;
+    return ret;
 }
openSUSE Build Service is sponsored by