summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Hjelm <hjelmn@me.com>2011-07-21 22:31:09 -0600
committerPeter Stuge <peter@stuge.se>2011-09-22 10:46:48 +0200
commita97762a8a121de1ad3deb9e861088b69bb6a155b (patch)
treead6fb7ca81319efde5dbe2ede229d80aa2965ed1
parent8723df191fcedc6161732fd06d12df392c6dea3f (diff)
downloadlibusb-a97762a8a121de1ad3deb9e861088b69bb6a155b.tar.gz
Darwin: fix libusb_get_device_list() and libusb_claim_interface() leaks
-rw-r--r--libusb/os/darwin_usb.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index 7c53b01..b021649 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -192,6 +192,9 @@ static usb_device_t **usb_get_next_device (io_iterator_t deviceIterator, UInt32
result = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID,
kIOCFPlugInInterfaceID, &plugInInterface,
&score);
+
+ /* we are done with the usb_device_t */
+ (void)IOObjectRelease(usbDevice);
if (kIOReturnSuccess == result && plugInInterface)
break;
@@ -201,7 +204,6 @@ static usb_device_t **usb_get_next_device (io_iterator_t deviceIterator, UInt32
if (!usbDevice)
return NULL;
- (void)IOObjectRelease(usbDevice);
(void)(*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(DeviceInterfaceID),
(LPVOID)&device);
@@ -1043,14 +1045,13 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int i
kresult = (*plugInInterface)->QueryInterface(plugInInterface,
CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID),
(LPVOID)&cInterface->interface);
+ /* We no longer need the intermediate plug-in */
+ IODestroyPlugInInterface (plugInInterface);
if (kresult || !cInterface->interface) {
usbi_err (HANDLE_CTX (dev_handle), "QueryInterface: %s", darwin_error_str(kresult));
return darwin_to_libusb (kresult);
}
- /* We no longer need the intermediate plug-in */
- (*plugInInterface)->Release(plugInInterface);
-
/* claim the interface */
kresult = (*(cInterface->interface))->USBInterfaceOpen(cInterface->interface);
if (kresult) {