msi: get proper buffer size in MsiEnumComponentQualifiersW

Aric Stewart aric at codeweavers.com
Mon Jul 11 13:58:22 CDT 2005


Properly resize the buffer based on ERROR_MORE_DATA.
also remember to free the allocated buffer.
-------------- next part --------------
Index: dlls/msi/registry.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/registry.c,v
retrieving revision 1.10
diff -u -r1.10 registry.c
--- dlls/msi/registry.c	7 Jun 2005 20:02:27 -0000	1.10
+++ dlls/msi/registry.c	11 Jul 2005 18:57:02 -0000
@@ -873,9 +873,18 @@
     rc = RegEnumValueW(key, iIndex, lpQualifierBuf, pcchQualifierBuf, NULL, 
                     NULL, (LPBYTE)full_buffer, &full_buffer_size);
 
+    if (rc == ERROR_MORE_DATA)
+    {
+        HeapFree(GetProcessHeap(),0,full_buffer);
+        full_buffer_size+=sizeof(WCHAR);
+        full_buffer = HeapAlloc(GetProcessHeap(),0,full_buffer_size);
+        rc = RegEnumValueW(key, iIndex, lpQualifierBuf, pcchQualifierBuf, NULL, 
+                    NULL, (LPBYTE)full_buffer, &full_buffer_size);
+    }
+    
     RegCloseKey(key);
 
-    if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA)
+    if (rc == ERROR_SUCCESS)
     {
         if (lpApplicationDataBuf && pcchApplicationDataBuf)
         {
@@ -897,6 +906,8 @@
         TRACE("Providing %s and %s\n", debugstr_w(lpQualifierBuf), 
                         debugstr_w(lpApplicationDataBuf));
     }
+
+    HeapFree(GetProcessHeap(),0,full_buffer);
 
     return rc;
 }


More information about the wine-patches mailing list