summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
Diffstat (limited to 'Xi')
-rw-r--r--Xi/listdev.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 91e8f2254..02d55ad4c 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -96,7 +96,7 @@ int
ProcXListInputDevices(register ClientPtr client)
{
xListInputDevicesReply rep;
- int numdevs;
+ int numdevs = 0;
int namesize = 1; /* need 1 extra byte for strcpy */
int size = 0;
int total_length;
@@ -115,12 +115,15 @@ ProcXListInputDevices(register ClientPtr client)
rep.sequenceNumber = client->sequence;
AddOtherInputDevices();
- numdevs = inputInfo.numDevices;
- for (d = inputInfo.devices; d; d = d->next)
+ for (d = inputInfo.devices; d; d = d->next) {
SizeDeviceInfo(d, &namesize, &size);
- for (d = inputInfo.off_devices; d; d = d->next)
+ numdevs++;
+ }
+ for (d = inputInfo.off_devices; d; d = d->next) {
SizeDeviceInfo(d, &namesize, &size);
+ numdevs++;
+ }
total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
devbuf = (char *)xalloc(total_length);