summaryrefslogtreecommitdiff
path: root/libusb
diff options
context:
space:
mode:
authorToby Gray <toby.gray@realvnc.com>2013-06-24 12:31:26 +0100
committerHans de Goede <hdegoede@redhat.com>2013-06-26 15:29:13 +0200
commit43fbe3df02551c4ad9b5976fbd5acc6280e66829 (patch)
tree5f172b65e363b2be261ac2617c85ff7cec50c4be /libusb
parent1b3c8272d6c9852977e87f4106a4669ebb25980b (diff)
downloadlibusb-43fbe3df02551c4ad9b5976fbd5acc6280e66829.tar.gz
WinCE: Fix device reference leak which caused crash on libusb_exit().
The Windows CE device allocation code has always had a bug where it would leak references to devices when they are allocated. This commit removes the reference leak. This leak was highlighted by the new hotplug code which now triggers a NULL pointer dereference if not all devices are unreferenced before libusb_exit is called. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'libusb')
-rw-r--r--libusb/os/wince_usb.c10
-rw-r--r--libusb/version_nano.h2
2 files changed, 5 insertions, 7 deletions
diff --git a/libusb/os/wince_usb.c b/libusb/os/wince_usb.c
index d8e8f55..76b559d 100644
--- a/libusb/os/wince_usb.c
+++ b/libusb/os/wince_usb.c
@@ -341,10 +341,10 @@ static int wince_get_device_list(
UKW_DEVICE devices[MAX_DEVICE_COUNT];
struct discovered_devs * new_devices = *discdevs;
DWORD count = 0, i;
- struct libusb_device *dev;
+ struct libusb_device *dev = NULL;
unsigned char bus_addr, dev_addr;
unsigned long session_id;
- BOOL success, need_unref = FALSE;
+ BOOL success;
DWORD release_list_offset = 0;
int r = LIBUSB_SUCCESS;
@@ -378,7 +378,6 @@ static int wince_get_device_list(
r = LIBUSB_ERROR_NO_MEM;
goto err_out;
}
- need_unref = TRUE;
r = init_device(dev, devices[i], bus_addr, dev_addr);
if (r < 0)
goto err_out;
@@ -391,14 +390,13 @@ static int wince_get_device_list(
r = LIBUSB_ERROR_NO_MEM;
goto err_out;
}
- need_unref = FALSE;
+ safe_unref_device(dev);
}
*discdevs = new_devices;
return r;
err_out:
*discdevs = new_devices;
- if (need_unref)
- libusb_unref_device(dev);
+ safe_unref_device(dev);
// Release the remainder of the unprocessed device list.
// The devices added to new_devices already will still be passed up to libusb,
// which can dispose of them at its leisure.
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 8184a6a..fde8fca 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10756
+#define LIBUSB_NANO 10757