diff options
-rw-r--r-- | src/XIProperties.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/XIProperties.c b/src/XIProperties.c index 5e58fb6..32436d1 100644 --- a/src/XIProperties.c +++ b/src/XIProperties.c @@ -38,6 +38,7 @@ #include <X11/extensions/XInput2.h> #include <X11/extensions/extutil.h> #include "XIint.h" +#include <limits.h> Atom* XIListProperties(Display* dpy, int deviceid, int *num_props_return) @@ -170,7 +171,7 @@ XIGetProperty(Display* dpy, int deviceid, Atom property, long offset, { xXIGetPropertyReq *req; xXIGetPropertyReply rep; - long nbytes, rbytes; + unsigned long nbytes, rbytes; XExtDisplayInfo *info = XInput_find_display(dpy); @@ -216,9 +217,11 @@ XIGetProperty(Display* dpy, int deviceid, Atom property, long offset, * recopy the string to make it null terminated. */ - nbytes = rep.num_items * rep.format/8; - rbytes = nbytes + 1; - *data = Xmalloc(rbytes); + if (rep.num_items < (INT_MAX / (rep.format/8))) { + nbytes = rep.num_items * rep.format/8; + rbytes = nbytes + 1; + *data = Xmalloc(rbytes); + } if (!(*data)) { _XEatDataWords(dpy, rep.length); |