]> sigrok.org Git - libserialport.git/commitdiff
windows: Properly handle return value of SetupDiOpenDevRegKey().
authorAurelien Jacobs <redacted>
Thu, 27 Nov 2014 16:41:23 +0000 (17:41 +0100)
committerAurelien Jacobs <redacted>
Thu, 27 Nov 2014 16:42:28 +0000 (17:42 +0100)
This fixes bug #499.

windows.c

index 523b8d0ac034ba0ebbb486df1c0b6b025ae817c4..bad62bf5806f063ce639824bdaec420c381c003d 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -353,9 +353,10 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port)
                CONFIGRET cr;
 
                /* check if this is the device we are looking for */
-               if (!(device_key = SetupDiOpenDevRegKey(device_info, &device_info_data,
-                                                       DICS_FLAG_GLOBAL, 0,
-                                                       DIREG_DEV, KEY_QUERY_VALUE)))
+               device_key = SetupDiOpenDevRegKey(device_info, &device_info_data,
+                                                 DICS_FLAG_GLOBAL, 0,
+                                                 DIREG_DEV, KEY_QUERY_VALUE);
+               if (device_key == INVALID_HANDLE_VALUE)
                        continue;
                size = sizeof(value);
                if (RegQueryValueExA(device_key, "PortName", NULL, &type, (LPBYTE)value,