[SETUPAPI] Fix broken control definition.
[reactos.git] / dll / win32 / setupapi / query.c
index 42dddc1..58c3d5b 100644 (file)
@@ -20,8 +20,6 @@
 
 #include "setupapi_private.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
-
 static const WCHAR source_disks_names[] =
     {'S','o','u','r','c','e','D','i','s','k','s','N','a','m','e','s',0};
 static const WCHAR source_disks_files[] =
@@ -98,8 +96,13 @@ BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl,
 
     if (InfSpec && SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE)
     {
-        len = lstrlenA(InfSpec) + 1;
+        len = MultiByteToWideChar(CP_ACP, 0, InfSpec, -1, NULL, 0);
         inf = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+        if (!inf)
+        {
+            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+            return FALSE;
+        }
         MultiByteToWideChar(CP_ACP, 0, InfSpec, -1, inf, len);
     }
 
@@ -114,7 +117,7 @@ BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl,
 
 /***********************************************************************
  *      SetupGetInfInformationW    (SETUPAPI.@)
- *
+ * 
  * BUGS
  *   Only handles the case when InfSpec is an INF handle.
  */
@@ -242,7 +245,7 @@ BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation,
  */
 BOOL WINAPI SetupQueryInfFileInformationW(PSP_INF_INFORMATION InfInformation,
                                           UINT InfIndex, PWSTR ReturnBuffer,
-                                          DWORD ReturnBufferSize, PDWORD RequiredSize)
+                                          DWORD ReturnBufferSize, PDWORD RequiredSize) 
 {
     DWORD len;
     LPWSTR ptr;
@@ -259,7 +262,7 @@ BOOL WINAPI SetupQueryInfFileInformationW(PSP_INF_INFORMATION InfInformation,
     if (InfIndex != 0)
         FIXME("Appended INF files are not handled\n");
 
-    ptr = (LPWSTR)&InfInformation->VersionData[0];
+    ptr = (LPWSTR)InfInformation->VersionData;
     len = lstrlenW(ptr);
 
     if (RequiredSize)
@@ -353,7 +356,10 @@ static LPWSTR get_source_id( HINF hinf, PINFCONTEXT context, PCWSTR filename )
     }
 
     if (!SetupDiGetActualSectionToInstallW(hinf, source_disks_names, Section, MAX_PATH, NULL, NULL))
+    {
+        HeapFree( GetProcessHeap(), 0, source_id );
         return NULL;
+    }
 
     if (!SetupFindFirstLineW( hinf, Section, source_id, context ) &&
         !SetupFindFirstLineW( hinf, source_disks_names, source_id, context ))
@@ -591,7 +597,7 @@ BOOL WINAPI SetupGetTargetPathW( HINF hinf, PINFCONTEXT context, PCWSTR section,
         else
         {
             SetLastError( ERROR_INSUFFICIENT_BUFFER );
-            HeapFree( GetProcessHeap(), 0, dir );
+            if (dir != systemdir) HeapFree( GetProcessHeap(), 0, dir );
             return FALSE;
         }
     }
@@ -658,7 +664,7 @@ BOOL WINAPI SetupQueryInfOriginalFileInformationW(
         return FALSE;
     }
 
-    inf_path = (LPWSTR)&InfInformation->VersionData[0];
+    inf_path = (LPWSTR)InfInformation->VersionData;
 
     /* FIXME: we should get OriginalCatalogName from CatalogFile line in
      * the original inf file and cache it, but that would require building a