diff options
author | Pauli Nieminen <ext-pauli.nieminen@nokia.com> | 2010-06-18 11:32:36 +0300 |
---|---|---|
committer | Pauli Nieminen <ext-pauli.nieminen@nokia.com> | 2010-07-13 11:26:13 +0300 |
commit | 8daf961d0fe6a1433c8248d984618a7e22ff88b8 (patch) | |
tree | 8c3e4f704a9a86bcff9e8c0be43e209437927b35 | |
parent | 3a6839b4a229aa59188025c9b285023110a20aad (diff) |
Always unlock display correctly
XISelectEvents and XIGetSelectedEvents were not unlocking display in all
return paths.
Reported-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
-rw-r--r-- | src/XISelEv.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/XISelEv.c b/src/XISelEv.c index 3c1f018..dad890e 100644 --- a/src/XISelEv.c +++ b/src/XISelEv.c @@ -48,11 +48,14 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks) xXIEventMask mask; int i; int len = 0; + int r = Success; XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) - return (NoSuchExtension); + if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) { + r = NoSuchExtension; + goto out; + } GetReq(XISelectEvents, req); req->reqType = info->codes->major_opcode; @@ -85,9 +88,10 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks) free(buff); } +out: UnlockDisplay(dpy); SyncHandle(); - return Success; + return r; } @@ -101,13 +105,11 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) xXIGetSelectedEventsReq *req; xXIGetSelectedEventsReply reply; + *num_masks_return = -1; XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) - { - *num_masks_return = -1; - return NULL; - } + goto out; GetReq(XIGetSelectedEvents, req); @@ -116,17 +118,17 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) req->win = win; if (!_XReply(dpy, (xReply *) &reply, 0, xFalse)) - goto error; + goto out; if (reply.num_masks == 0) { *num_masks_return = 0; - return NULL; + goto out; } mask_in = Xmalloc(reply.length * 4); if (!mask_in) - goto error; + goto out; _XRead(dpy, (char*)mask_in, reply.length * 4); @@ -144,7 +146,7 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) mask_out = Xmalloc(len); if (!mask_out) - goto error; + goto out; mi = mask_in; mask = (unsigned char*)&mask_out[reply.num_masks]; @@ -161,16 +163,11 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) *num_masks_return = reply.num_masks; +out: Xfree(mask_in); - return mask_out; - -error: - if (mask_in) - Xfree(mask_in); - *num_masks_return = -1; UnlockDisplay(dpy); SyncHandle(); - return NULL; + return mask_out; } |