msi 6: pcchValue represents the length of szValue in TCHARS, not bytes

James Hawkins truiken at gmail.com
Wed Jun 27 18:32:29 CDT 2007


Hi,

Changelog:
* pcchValue represents the length of szValue in TCHARS, not bytes.

 dlls/msi/source.c       |    9 +++++++--
 dlls/msi/tests/source.c |   24 ++++++------------------
 2 files changed, 13 insertions(+), 20 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/source.c b/dlls/msi/source.c
index 58b8049..2b9812a 100644
--- a/dlls/msi/source.c
+++ b/dlls/msi/source.c
@@ -184,7 +184,7 @@ UINT WINAPI MsiSourceListGetInfoA( LPCST
     ret = MsiSourceListGetInfoW(product, usersid, dwContext, dwOptions,
                                  property, value, pcchValue);
     if (ret == ERROR_SUCCESS)
-        WideCharToMultiByte(CP_ACP, 0, value, -1, szValue, *pcchValue, NULL, NULL);
+        WideCharToMultiByte(CP_ACP, 0, value, -1, szValue, *pcchValue + 1, NULL, NULL);
 
 done:
     msi_free(product);
@@ -330,10 +330,15 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWS
     }
     else if (strcmpW(INSTALLPROPERTY_PACKAGENAMEW, szProperty)==0)
     {
+        *pcchValue = *pcchValue * sizeof(WCHAR);
         rc = RegQueryValueExW(sourcekey, INSTALLPROPERTY_PACKAGENAMEW, 0, 0, 
-                (LPBYTE)szValue, pcchValue);
+                              (LPBYTE)szValue, pcchValue);
         if (rc != ERROR_SUCCESS && rc != ERROR_MORE_DATA)
             rc = ERROR_SUCCESS;
+        if (*pcchValue)
+            *pcchValue = (*pcchValue - 1) / sizeof(WCHAR);
+        if (szValue)
+            szValue[*pcchValue] = '\0';
     }
     else
     {
diff --git a/dlls/msi/tests/source.c b/dlls/msi/tests/source.c
index 546217f..58c2e86 100644
--- a/dlls/msi/tests/source.c
+++ b/dlls/msi/tests/source.c
@@ -220,21 +220,15 @@ static void test_MsiSourceListGetInfo(vo
     r = MsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
                               MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(size == 11, "Expected 11, got %d\n", size);
-    }
+    ok(size == 11, "Expected 11, got %d\n", size);
 
     /* read the value, don't change size */
     lstrcpyA(value, "aaa");
     r = MsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
                               MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
-    todo_wine
-    {
-        ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
-        ok(!lstrcmpA(value, "aaa"), "Expected 'aaa', got %s\n", value);
-        ok(size == 11, "Expected 11, got %d\n", size);
-    }
+    ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
+    ok(!lstrcmpA(value, "aaa"), "Expected 'aaa', got %s\n", value);
+    ok(size == 11, "Expected 11, got %d\n", size);
 
     /* read the value, fix size */
     size++;
@@ -242,10 +236,7 @@ static void test_MsiSourceListGetInfo(vo
                               MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
     ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
-    todo_wine
-    {
-        ok(size == 11, "Expected 11, got %d\n", size);
-    }
+    ok(size == 11, "Expected 11, got %d\n", size);
 
     /* empty property now that product key exists */
     size = 0xdeadbeef;
@@ -277,10 +268,7 @@ static void test_MsiSourceListGetInfo(vo
     r = MsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
                               4, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(size == 11, "Expected 11, got %d\n", size);
-    }
+    ok(size == 11, "Expected 11, got %d\n", size);
 
     RegDeleteValueA(hkey, "nonexistent");
     RegDeleteValueA(hkey, "PackageName");
-- 
1.4.1


More information about the wine-patches mailing list