summaryrefslogtreecommitdiff
path: root/src/XIPassiveGrab.c
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-07-08 17:01:03 -0400
committerPeter Hutterer <peter.hutterer@who-t.net>2014-07-10 08:48:01 +1000
commiteb0c522e0ce5763b6bf181f1236e78ca94f98b7e (patch)
tree65000945a835d25b52fe382561e2b3574c27f293 /src/XIPassiveGrab.c
parent288f3362133a36e2c370eb34caf6b5ed6c0764ca (diff)
XIPassiveGrab: Fix display locking inside _XIPassiveGrabDevice for error paths
The code here before would just leave the display locked on error, which is all sorts of broken. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/XIPassiveGrab.c')
-rw-r--r--src/XIPassiveGrab.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/XIPassiveGrab.c b/src/XIPassiveGrab.c
index baadccb..f3a9924 100644
--- a/src/XIPassiveGrab.c
+++ b/src/XIPassiveGrab.c
@@ -44,6 +44,7 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
xXIPassiveGrabDeviceReply reply;
xXIGrabModifierInfo *failed_mods;
int len = 0, i;
+ int ret = -1;
char *buff;
XExtDisplayInfo *extinfo = XInput_find_display(dpy);
@@ -54,11 +55,11 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
if (mask->mask_len > INT_MAX - 3 ||
(mask->mask_len + 3)/4 >= 0xffff)
- return -1;
+ goto out;
buff = calloc(4, (mask->mask_len + 3)/4);
if (!buff)
- return -1;
+ goto out;
GetReq(XIPassiveGrabDevice, req);
req->reqType = extinfo->codes->major_opcode;
@@ -85,15 +86,11 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
free(buff);
if (!_XReply(dpy, (xReply *)&reply, 0, xFalse))
- {
- UnlockDisplay(dpy);
- SyncHandle();
- return -1;
- }
+ goto out;
failed_mods = calloc(reply.num_modifiers, sizeof(xXIGrabModifierInfo));
if (!failed_mods)
- return -1;
+ goto out;
_XRead(dpy, (char*)failed_mods, reply.num_modifiers * sizeof(xXIGrabModifierInfo));
for (i = 0; i < reply.num_modifiers && i < num_modifiers; i++)
@@ -103,9 +100,12 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
}
free(failed_mods);
+ ret = reply.num_modifiers;
+
+ out:
UnlockDisplay(dpy);
SyncHandle();
- return reply.num_modifiers;
+ return ret;
}
int