From 8a2f7b5c0520e6099f2c624cd0994c60867c1628 Mon Sep 17 00:00:00 2001 From: Vitali Lovich Date: Fri, 16 Sep 2011 08:48:28 -0600 Subject: [PATCH] Darwin: fix potential leak on libusb_claim_interface() error --- libusb/os/darwin_usb.c | 7 ++++--- 1 file 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), -- 2.7.4