summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/XQueryDv.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/XQueryDv.c b/src/XQueryDv.c
index d9495c2..637d5cf 100644
--- a/src/XQueryDv.c
+++ b/src/XQueryDv.c
@@ -69,7 +69,7 @@ XQueryDeviceState(
xQueryDeviceStateReply rep;
XDeviceState *state = NULL;
XInputClass *any, *Any;
- char *data;
+ char *data = NULL;
XExtDisplayInfo *info = XInput_find_display(dpy);
LockDisplay(dpy);
@@ -81,20 +81,15 @@ XQueryDeviceState(
req->ReqType = X_QueryDeviceState;
req->deviceid = dev->device_id;
- if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return (XDeviceState *) NULL;
- }
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
+ goto out;
rlen = rep.length << 2;
if (rlen > 0) {
data = Xmalloc(rlen);
if (!data) {
_XEatData(dpy, (unsigned long)rlen);
- UnlockDisplay(dpy);
- SyncHandle();
- return ((XDeviceState *) NULL);
+ goto out;
}
_XRead(dpy, data, rlen);
@@ -117,11 +112,9 @@ XQueryDeviceState(
any = (XInputClass *) ((char *)any + any->length);
}
state = (XDeviceState *) Xmalloc(size + sizeof(XDeviceState));
- if (!state) {
- UnlockDisplay(dpy);
- SyncHandle();
- return ((XDeviceState *) NULL);
- }
+ if (!state)
+ goto out;
+
state->device_id = dev->device_id;
state->num_classes = rep.num_classes;
state->data = (XInputClass *) (state + 1);
@@ -175,8 +168,9 @@ XQueryDeviceState(
}
any = (XInputClass *) ((char *)any + any->length);
}
- Xfree(data);
}
+out:
+ Xfree(data);
UnlockDisplay(dpy);
SyncHandle();