diff options
author | Vitali Lovich <vlovich@gmail.com> | 2011-09-16 08:48:28 -0600 |
---|---|---|
committer | Peter Stuge <peter@stuge.se> | 2011-09-22 11:26:17 +0200 |
commit | a14355aa5fa9525886b4f261c6a7a1c0f80b83fa (patch) | |
tree | c3753e40211a0f9ff7d4770e8a2921be77f1e263 | |
parent | 6171bc8bf9b25d73af665f40a65f808560c7a886 (diff) | |
download | libusb-a14355aa5fa9525886b4f261c6a7a1c0f80b83fa.tar.gz |
Darwin: fix potential leak on libusb_claim_interface() error
-rw-r--r-- | libusb/os/darwin_usb.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index 5451f23..6e9d36f 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -1040,6 +1040,10 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int i /* get an interface to the device's interface */ kresult = IOCreatePlugInInterfaceForService (usbInterface, kIOUSBInterfaceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); + + /* ignore release error */ + (void)IOObjectRelease (usbInterface); + if (kresult) { usbi_err (HANDLE_CTX (dev_handle), "IOCreatePlugInInterfaceForService: %s", darwin_error_str(kresult)); return darwin_to_libusb (kresult); @@ -1050,9 +1054,6 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int i return LIBUSB_ERROR_NOT_FOUND; } - /* ignore release error */ - (void)IOObjectRelease (usbInterface); - /* Do the actual claim */ kresult = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID), |