Commit eb0c522e authored by Jasper St. Pierre's avatar Jasper St. Pierre Committed by Peter Hutterer

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's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 288f3362
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment