diff options
-rw-r--r-- | src/XIPassiveGrab.c | 18 |
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 |