From fc93cb6af83358f1104fc842e65ccda9b8320904 Mon Sep 17 00:00:00 2001 From: enami <287238+enami@users.noreply.github.com> Date: Fri, 26 Nov 2021 13:09:47 +0900 Subject: [PATCH] fix: OSX List Make sure necessary cleanups such as uv_mutex_unlock are called always. (#2343) --- packages/bindings/src/darwin_list.cpp | 34 ++++++++++++--------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/packages/bindings/src/darwin_list.cpp b/packages/bindings/src/darwin_list.cpp index a3f5d65..6e1a849 100644 --- a/packages/bindings/src/darwin_list.cpp +++ b/packages/bindings/src/darwin_list.cpp @@ -237,27 +237,23 @@ static stDeviceListItem* GetSerialDevices() { kernResult = IOCreatePlugInInterfaceForService(device, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); - if ((kIOReturnSuccess != kernResult) || !plugInInterface) { - continue; + if ((kIOReturnSuccess == kernResult) && plugInInterface) { + // Use the plugin interface to retrieve the device interface. + res = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), + reinterpret_cast (&deviceInterface)); + + // Now done with the plugin interface. + (*plugInInterface)->Release(plugInInterface); + + if (!res && deviceInterface != NULL) { + // Extract the desired Information + ExtractUsbInformation(serialDevice, deviceInterface); + + // Release the Interface + (*deviceInterface)->Release(deviceInterface); + } } - // Use the plugin interface to retrieve the device interface. - res = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), - reinterpret_cast (&deviceInterface)); - - // Now done with the plugin interface. - (*plugInInterface)->Release(plugInInterface); - - if (res || deviceInterface == NULL) { - continue; - } - - // Extract the desired Information - ExtractUsbInformation(serialDevice, deviceInterface); - - // Release the Interface - (*deviceInterface)->Release(deviceInterface); - // Release the device (void) IOObjectRelease(device); }