diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-10-13 14:02:51 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-10-13 14:02:51 +0200 |
commit | 133c91f732c6259fa9099100cd5b781d5b1cbfa1 (patch) | |
tree | 478aa88a8c42cbcb8221dd6680a16131556b49be /nx-X11/lib/X11/GetMoEv.c | |
parent | 051d521f6e20761ba6831cecd91883da960fa931 (diff) | |
parent | a9f623f0a63372ca0705e8394fadf514dec55b1c (diff) | |
download | nx-libs-133c91f732c6259fa9099100cd5b781d5b1cbfa1.tar.gz nx-libs-133c91f732c6259fa9099100cd5b781d5b1cbfa1.tar.bz2 nx-libs-133c91f732c6259fa9099100cd5b781d5b1cbfa1.zip |
Merge branch 'uli42-pr/libX11_debian_backports' into 3.6.x
Attributes GH PR #215: https://github.com/ArcticaProject/nx-libs/pull/215
Diffstat (limited to 'nx-X11/lib/X11/GetMoEv.c')
-rw-r--r-- | nx-X11/lib/X11/GetMoEv.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/nx-X11/lib/X11/GetMoEv.c b/nx-X11/lib/X11/GetMoEv.c index 3db176feb..ad9c77277 100644 --- a/nx-X11/lib/X11/GetMoEv.c +++ b/nx-X11/lib/X11/GetMoEv.c @@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group. #include <config.h> #endif #include "Xlibint.h" +#include <limits.h> XTimeCoord *XGetMotionEvents( register Display *dpy, @@ -39,7 +40,6 @@ XTimeCoord *XGetMotionEvents( xGetMotionEventsReply rep; register xGetMotionEventsReq *req; XTimeCoord *tc = NULL; - long nbytes; LockDisplay(dpy); GetReq(GetMotionEvents, req); req->window = w; @@ -52,26 +52,22 @@ XTimeCoord *XGetMotionEvents( return (NULL); } - if (rep.nEvents) { - if (! (tc = (XTimeCoord *) - Xmalloc( (unsigned) - (nbytes = (long) rep.nEvents * sizeof(XTimeCoord))))) { - _XEatData (dpy, (unsigned long) nbytes); - UnlockDisplay(dpy); - SyncHandle(); - return (NULL); - } + if (rep.nEvents && (rep.nEvents < (INT_MAX / sizeof(XTimeCoord)))) + tc = Xmalloc(rep.nEvents * sizeof(XTimeCoord)); + if (tc == NULL) { + /* server returned either no events or a bad event count */ + *nEvents = 0; + _XEatDataWords (dpy, rep.length); } - - *nEvents = rep.nEvents; - nbytes = SIZEOF (xTimecoord); + else { register XTimeCoord *tcptr; - register int i; + unsigned int i; xTimecoord xtc; + *nEvents = (int) rep.nEvents; for (i = rep.nEvents, tcptr = tc; i > 0; i--, tcptr++) { - _XRead (dpy, (char *) &xtc, nbytes); + _XRead (dpy, (char *) &xtc, SIZEOF (xTimecoord)); tcptr->time = xtc.time; tcptr->x = cvtINT16toShort (xtc.x); tcptr->y = cvtINT16toShort (xtc.y); |