msi: fixes for MsiGetProductInfo

Aric Stewart aric at codeweavers.com
Thu Jun 2 15:05:55 CDT 2005


with help from Robert Shearman
Locate where a buffer size is not being set and correctly handle the 
buffer size conversion from W to A
-------------- next part --------------
Index: dlls/msi/msi.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msi.c,v
retrieving revision 1.84
diff -u -r1.84 msi.c
--- dlls/msi/msi.c	1 Jun 2005 19:57:42 -0000	1.84
+++ dlls/msi/msi.c	2 Jun 2005 20:03:22 -0000
@@ -462,6 +462,7 @@
 {
     LPWSTR szwProduct = NULL, szwAttribute = NULL, szwBuffer = NULL;
     UINT r = ERROR_OUTOFMEMORY;
+    DWORD pcchwValueBuf = 0;
 
     TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
           szBuffer, pcchValueBuf);
@@ -483,14 +484,17 @@
     if( szBuffer )
     {
         szwBuffer = HeapAlloc( GetProcessHeap(), 0, (*pcchValueBuf) * sizeof(WCHAR) );
+        pcchwValueBuf = *pcchValueBuf;
         if( !szwBuffer )     
             goto end;
     }
 
-    r = MsiGetProductInfoW( szwProduct, szwAttribute, szwBuffer, pcchValueBuf );
+    r = MsiGetProductInfoW( szwProduct, szwAttribute, szwBuffer, 
+                            &pcchwValueBuf );
 
     if( ERROR_SUCCESS == r )
-        WideCharToMultiByte(CP_ACP, 0, szwBuffer, -1, szBuffer, *pcchValueBuf, NULL, NULL);
+        *pcchValueBuf = WideCharToMultiByte(CP_ACP, 0, szwBuffer, pcchwValueBuf,
+                        szBuffer, *pcchValueBuf, NULL, NULL);
 
 end:
     HeapFree( GetProcessHeap(), 0, szwProduct );
@@ -569,6 +573,8 @@
         FIXME("0 (zero) if advertised, 1(one) if per machine.\n");
         if (szBuffer)
             szBuffer[0] = 1;
+        if (pcchValueBuf)
+            *pcchValueBuf = 1;
         r = ERROR_SUCCESS;
     }
     else


More information about the wine-patches mailing list