Commit 22ae8d4f authored by Michal Srb's avatar Michal Srb Committed by Peter Hutterer

Fix double unlock when _XiCheckExtInit return -1.

_XiCheckExtInit unlocks the display if it fails and returns -1. Most callers
account for it properly, but few didn't.
Signed-off-by: default avatarMichal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 71a42145
......@@ -51,7 +51,7 @@ XIListProperties(Display* dpy, int deviceid, int *num_props_return)
LockDisplay(dpy);
*num_props_return = 0;
if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1)
goto cleanup;
goto cleanup_unlocked;
GetReq(XIListProperties, req);
req->reqType = info->codes->major_opcode;
......@@ -76,6 +76,7 @@ XIListProperties(Display* dpy, int deviceid, int *num_props_return)
cleanup:
UnlockDisplay(dpy);
cleanup_unlocked:
SyncHandle();
return props;
}
......
......@@ -50,7 +50,7 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return)
LockDisplay(dpy);
if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1)
goto error;
goto error_unlocked;
GetReq(XIQueryDevice, req);
req->reqType = extinfo->codes->major_opcode;
......@@ -105,6 +105,7 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return)
error:
UnlockDisplay(dpy);
error_unlocked:
SyncHandle();
*ndevices_return = -1;
return NULL;
......
......@@ -41,10 +41,8 @@ XIQueryVersion(Display *dpy, int *major_inout, int *minor_inout)
XExtDisplayInfo *info = XInput_find_display(dpy);
LockDisplay(dpy);
rc = _xiQueryVersion(dpy, major_inout, minor_inout, info);
UnlockDisplay(dpy);
SyncHandle();
return rc;
}
......@@ -55,6 +53,8 @@ _xiQueryVersion(Display * dpy, int *major, int *minor, XExtDisplayInfo *info)
xXIQueryVersionReq *req;
xXIQueryVersionReply rep;
LockDisplay(dpy);
/* This could mean either a malloc problem, or supported
version < XInput_2_0 */
if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1)
......@@ -82,9 +82,13 @@ _xiQueryVersion(Display * dpy, int *major, int *minor, XExtDisplayInfo *info)
req->minor_version = *minor;
if (!_XReply(dpy, (xReply*)&rep, 0, xTrue)) {
UnlockDisplay(dpy);
return BadImplementation;
}
*major = rep.major_version;
*minor = rep.minor_version;
UnlockDisplay(dpy);
return Success;
}
......@@ -60,7 +60,7 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks)
LockDisplay(dpy);
if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1) {
r = NoSuchExtension;
goto out;
goto out_unlocked;
}
for (i = 0; i < num_masks; i++) {
......@@ -114,6 +114,7 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks)
free(buff);
out:
UnlockDisplay(dpy);
out_unlocked:
SyncHandle();
return r;
......@@ -134,7 +135,7 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
*num_masks_return = -1;
LockDisplay(dpy);
if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1)
goto out;
goto out_unlocked;
GetReq(XIGetSelectedEvents, req);
......@@ -209,6 +210,8 @@ out:
Xfree(mask_in);
UnlockDisplay(dpy);
out_unlocked:
SyncHandle();
return mask_out;
......
......@@ -51,7 +51,7 @@ XListDeviceProperties(Display* dpy, XDevice* dev, int *nprops_return)
LockDisplay(dpy);
*nprops_return = 0;
if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1)
goto cleanup;
return NULL;
GetReq(ListDeviceProperties, req);
req->reqType = info->codes->major_opcode;
......
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