Hans Leidekker : msi: Fix parsing of patch product codes (valgrind).

Alexandre Julliard julliard at winehq.org
Wed Jan 12 13:16:53 CST 2011


Module: wine
Branch: master
Commit: d08378a06f90ececa883d71ea02f7619f38aef29
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d08378a06f90ececa883d71ea02f7619f38aef29

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Jan 12 14:04:28 2011 +0100

msi: Fix parsing of patch product codes (valgrind).

---

 dlls/msi/action.c  |    3 +--
 dlls/msi/msi.c     |   21 +++++++++------------
 dlls/msi/msipriv.h |    1 +
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 8f2d116..725ea2f 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -465,8 +465,7 @@ UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine,
     return ERROR_SUCCESS;
 }
 
-
-static LPWSTR* msi_split_string( LPCWSTR str, WCHAR sep )
+WCHAR **msi_split_string( const WCHAR *str, WCHAR sep )
 {
     LPCWSTR pc;
     LPWSTR p, *ret = NULL;
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 266bd89..948ae35 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -299,7 +299,8 @@ done:
     return r;
 }
 
-static UINT get_patch_product_codes( LPCWSTR szPatchPackage, WCHAR **product_codes )
+
+static UINT get_patch_product_codes( LPCWSTR szPatchPackage, WCHAR ***product_codes )
 {
     MSIHANDLE patch, info = 0;
     UINT r, type;
@@ -332,23 +333,22 @@ static UINT get_patch_product_codes( LPCWSTR szPatchPackage, WCHAR **product_cod
     }
 
     r = MsiSummaryInfoGetPropertyW( info, PID_TEMPLATE, &type, NULL, NULL, codes, &size );
-    if (r != ERROR_SUCCESS)
-        msi_free( codes );
-    else
-        *product_codes = codes;
+    if (r == ERROR_SUCCESS)
+        *product_codes = msi_split_string( codes, ';' );
 
 done:
     MsiCloseHandle( info );
     MsiCloseHandle( patch );
+    msi_free( codes );
     return r;
 }
 
 static UINT MSI_ApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szProductCode, LPCWSTR szCommandLine)
 {
-    UINT r;
+    UINT r, i;
     DWORD size;
     LPCWSTR cmd_ptr = szCommandLine;
-    LPWSTR beg, end, cmd, codes = NULL;
+    LPWSTR cmd, *codes = NULL;
     BOOL succeeded = FALSE;
 
     static const WCHAR fmt[] = {'%','s',' ','P','A','T','C','H','=','"','%','s','"',0};
@@ -376,17 +376,14 @@ static UINT MSI_ApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szProductCode, LPCWS
         r = MsiConfigureProductExW(szProductCode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
     else
     {
-        beg = codes;
-        while ((end = strchrW(beg, '}')))
+        for (i = 0; codes[i]; i++)
         {
-            *(end + 1) = '\0';
-            r = MsiConfigureProductExW(beg, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
+            r = MsiConfigureProductExW(codes[i], INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
             if (r == ERROR_SUCCESS)
             {
                 TRACE("patch applied\n");
                 succeeded = TRUE;
             }
-            beg = end + 2;
         }
 
         if (succeeded)
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 3f482ea..47a35b8 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -958,6 +958,7 @@ extern void msi_feature_set_state(MSIPACKAGE *, MSIFEATURE *, INSTALLSTATE);
 extern MSIASSEMBLY *load_assembly(MSIPACKAGE *, MSICOMPONENT *);
 extern UINT install_assembly(MSIPACKAGE *, MSICOMPONENT *);
 extern WCHAR *font_version_from_file(const WCHAR *);
+extern WCHAR **msi_split_string(const WCHAR *, WCHAR);
 
 /* media */
 




More information about the wine-cvs mailing list