From f6ef0fca4b36657c1a0885c18cc4c4afcb4f7339 Mon Sep 17 00:00:00 2001 From: Dave Camarillo Date: Fri, 23 Sep 2011 11:56:58 +0100 Subject: [PATCH] Windows: Fix crash during enumeration with >= 64 connected devices * indexes were outgrowing the unref_list array before realloc, resulting in out of bound access and crash. --- libusb/os/windows_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index dcc7e7f..4d4c92c 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -1421,7 +1421,7 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered windows_device_priv_init(dev); // Keep track of devices that need unref unref_list[unref_cur++] = dev; - if (unref_cur > unref_size) { + if (unref_cur >= unref_size) { unref_size += 64; unref_list = realloc(unref_list, unref_size*sizeof(libusb_device*)); if (unref_list == NULL) { -- 2.7.4