diff options
Diffstat (limited to 'lib/libXi/src/XIQueryDevice.c')
-rw-r--r-- | lib/libXi/src/XIQueryDevice.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/libXi/src/XIQueryDevice.c b/lib/libXi/src/XIQueryDevice.c index c22aee142..4be1ecaf2 100644 --- a/lib/libXi/src/XIQueryDevice.c +++ b/lib/libXi/src/XIQueryDevice.c @@ -22,6 +22,10 @@ * */ +#if HAVE_CONFIG_H +#include <config.h> +#endif + #include <stdint.h> #include <X11/Xlibint.h> #include <X11/extensions/XI2proto.h> @@ -70,6 +74,8 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return) for (i = 0; i < reply.num_devices; i++) { + int nclasses; + size_t sz; XIDeviceInfo *lib = &info[i]; xXIDeviceInfo *wire = (xXIDeviceInfo*)ptr; @@ -77,8 +83,7 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return) lib->use = wire->use; lib->attachment = wire->attachment; lib->enabled = wire->enabled; - lib->num_classes = wire->num_classes; - lib->classes = (XIAnyClassInfo**)&lib[1]; + nclasses = wire->num_classes; ptr += sizeof(xXIDeviceInfo); @@ -86,8 +91,11 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return) strncpy(lib->name, ptr, wire->name_len); ptr += ((wire->name_len + 3)/4) * 4; - lib->classes = Xmalloc(size_classes((xXIAnyInfo*)ptr, lib->num_classes)); - ptr += copy_classes(lib, (xXIAnyInfo*)ptr, &lib->num_classes); + sz = size_classes((xXIAnyInfo*)ptr, nclasses); + lib->classes = Xmalloc(sz); + ptr += copy_classes(lib, (xXIAnyInfo*)ptr, &nclasses); + /* We skip over unused classes */ + lib->num_classes = nclasses; } Xfree(buf); |