[PATCH libXi 1/7] Fix double unlock when _XiCheckExtInit return -1.
Michal Srb
msrb at suse.com
Sat Nov 1 11:00:51 PDT 2014
_XiCheckExtInit unlocks the display if it fails and returns -1. Most callers
account for it properly, but few didn't.
Signed-off-by: Michal Srb <msrb at suse.com>
---
src/XIProperties.c | 3 ++-
src/XIQueryDevice.c | 3 ++-
src/XIQueryVersion.c | 8 ++++++--
src/XISelEv.c | 7 +++++--
src/XListDProp.c | 2 +-
5 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/XIProperties.c b/src/XIProperties.c
index 32436d1..a16e182 100644
--- a/src/XIProperties.c
+++ b/src/XIProperties.c
@@ -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;
}
diff --git a/src/XIQueryDevice.c b/src/XIQueryDevice.c
index 4be1eca..fb8504f 100644
--- a/src/XIQueryDevice.c
+++ b/src/XIQueryDevice.c
@@ -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;
diff --git a/src/XIQueryVersion.c b/src/XIQueryVersion.c
index 3f2e73e..57bd079 100644
--- a/src/XIQueryVersion.c
+++ b/src/XIQueryVersion.c
@@ -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;
}
diff --git a/src/XISelEv.c b/src/XISelEv.c
index 55c0a6a..aeee1e3 100644
--- a/src/XISelEv.c
+++ b/src/XISelEv.c
@@ -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;
diff --git a/src/XListDProp.c b/src/XListDProp.c
index bde6cb5..55f3c51 100644
--- a/src/XListDProp.c
+++ b/src/XListDProp.c
@@ -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;
--
1.8.4.5
More information about the xorg-devel
mailing list