[SETUPAPI] Fix broken control definition.
[reactos.git] / dll / win32 / setupapi / interface.c
index e7556ce..172d045 100644 (file)
@@ -2,7 +2,7 @@
  * SetupAPI interface-related functions
  *
  * Copyright 2000 Andreas Mohr for CodeWeavers
- *           2005-2006 Hervé Poussineau (hpoussin@reactos.org)
+ *           2005-2006 Herv Poussineau (hpoussin@reactos.org)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -21,8 +21,6 @@
 
 #include "setupapi_private.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
-
 /* Unicode constants */
 static const WCHAR AddInterface[]  = {'A','d','d','I','n','t','e','r','f','a','c','e',0};
 static const WCHAR ClassGUID[]  = {'C','l','a','s','s','G','U','I','D',0};
@@ -99,7 +97,8 @@ SETUP_CreateInterfaceList(
     hInterfaceKey = SetupDiOpenClassRegKeyExW(InterfaceGuid, KEY_ENUMERATE_SUB_KEYS, DIOCR_INTERFACE, MachineName, NULL);
     if (hInterfaceKey == INVALID_HANDLE_VALUE)
     {
-        rc = GetLastError();
+        /* Key doesn't exist. Let's keep it empty */
+        rc = ERROR_SUCCESS;
         goto cleanup;
     }
 
@@ -156,7 +155,7 @@ SETUP_CreateInterfaceList(
             list->HKLM,
             REGSTR_PATH_SYSTEMENUM,
             0, /* Options */
-            0,
+            READ_CONTROL,
             &hEnumKey);
         if (rc != ERROR_SUCCESS)
             goto cleanup;
@@ -233,7 +232,7 @@ SETUP_CreateInterfaceList(
 
             /* Step 2. Create an interface list for this element */
             HeapFree(GetProcessHeap(), 0, pSymbolicLink);
-            pSymbolicLink = HeapAlloc(GetProcessHeap(), 0, (dwLength + 1) * sizeof(WCHAR));
+            pSymbolicLink = HeapAlloc(GetProcessHeap(), 0, dwLength + sizeof(WCHAR));
             if (!pSymbolicLink)
             {
                 rc = ERROR_NOT_ENOUGH_MEMORY;
@@ -587,6 +586,7 @@ SetupDiOpenDeviceInterfaceRegKey(
         Slash = wcsrchr(Path, '\\');
         if (!Guid || !Slash)
         {
+            HeapFree(GetProcessHeap(), 0, Path);
             SetLastError(ERROR_INVALID_PARAMETER);
             return INVALID_HANDLE_VALUE;
         }