ao-tools: ao-list was crashing with more than 3 devices connected
authorKeith Packard <keithp@keithp.com>
Sat, 13 Aug 2011 22:00:14 +0000 (15:00 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 14 Aug 2011 01:44:26 +0000 (18:44 -0700)
the list of devices was getting realloced for each new device, but
that realloc was too small.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/lib/cc-usbdev.c

index afa91d49fed1f3e3fbfcfb7d815ff60385c1263b..a19e231c9fe724cd4b473d6f7ca3c6037acdd850 100644 (file)
@@ -223,7 +223,7 @@ cc_usbdevs_scan(void)
                if (dev->idVendor == 0xfffe && dev->tty) {
                        if (devs->dev)
                                devs->dev = realloc(devs->dev,
-                                                   devs->ndev + 1 * sizeof (struct usbdev *));
+                                                   (devs->ndev + 1) * sizeof (struct usbdev *));
                        else
                                devs->dev = malloc (sizeof (struct usbdev *));
                        devs->dev[devs->ndev++] = dev;