summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPauli Nieminen <ext-pauli.nieminen@nokia.com>2010-06-14 10:37:56 +0300
committerPauli Nieminen <ext-pauli.nieminen@nokia.com>2010-07-13 11:26:13 +0300
commit850288fee663c07fbd491859629543f78bbadd3c (patch)
tree02e4ed337a5ee7206f4d397502d3269fdbf5ba09 /src
parent9ca839742b49d49e98a17baa40c9662ee76c397f (diff)
Use single error path in XGetFeedbackControl
This reduces code duplication and fixes possible leak of f. f would leak if allocation of Feedback fails. Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> Reviewed-by: Julien Cristau <jcristau@debian.org>
Diffstat (limited to 'src')
-rw-r--r--src/XGetFCtl.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/XGetFCtl.c b/src/XGetFCtl.c
index 61df7cf..3d64404 100644
--- a/src/XGetFCtl.c
+++ b/src/XGetFCtl.c
@@ -83,20 +83,16 @@ XGetFeedbackControl(
req->ReqType = X_GetFeedbackControl;
req->deviceid = dev->device_id;
- if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return (XFeedbackState *) NULL;
- }
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
+ goto out;
+
if (rep.length > 0) {
*num_feedbacks = rep.num_feedbacks;
nbytes = (long)rep.length << 2;
f = (xFeedbackState *) Xmalloc((unsigned)nbytes);
if (!f) {
_XEatData(dpy, (unsigned long)nbytes);
- UnlockDisplay(dpy);
- SyncHandle();
- return (XFeedbackState *) NULL;
+ goto out;
}
sav = f;
_XRead(dpy, (char *)f, nbytes);
@@ -134,11 +130,9 @@ XGetFeedbackControl(
}
Feedback = (XFeedbackState *) Xmalloc((unsigned)size);
- if (!Feedback) {
- UnlockDisplay(dpy);
- SyncHandle();
- return (XFeedbackState *) NULL;
- }
+ if (!Feedback)
+ goto out;
+
Sav = Feedback;
f = sav;
@@ -253,8 +247,9 @@ XGetFeedbackControl(
f = (xFeedbackState *) ((char *)f + f->length);
Feedback = (XFeedbackState *) ((char *)Feedback + Feedback->length);
}
- XFree((char *)sav);
}
+out:
+ XFree((char *)sav);
UnlockDisplay(dpy);
SyncHandle();