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

This commit is contained in:
Hans Leidekker 2011-01-12 14:04:28 +01:00 committed by Alexandre Julliard
parent 94f4c0f07d
commit d08378a06f
3 changed files with 11 additions and 14 deletions

View File

@ -465,8 +465,7 @@ UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine,
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
WCHAR **msi_split_string( const WCHAR *str, WCHAR sep )
static LPWSTR* msi_split_string( LPCWSTR str, WCHAR sep )
{ {
LPCWSTR pc; LPCWSTR pc;
LPWSTR p, *ret = NULL; LPWSTR p, *ret = NULL;

View File

@ -299,7 +299,8 @@ done:
return r; 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; MSIHANDLE patch, info = 0;
UINT r, type; 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 ); r = MsiSummaryInfoGetPropertyW( info, PID_TEMPLATE, &type, NULL, NULL, codes, &size );
if (r != ERROR_SUCCESS) if (r == ERROR_SUCCESS)
msi_free( codes ); *product_codes = msi_split_string( codes, ';' );
else
*product_codes = codes;
done: done:
MsiCloseHandle( info ); MsiCloseHandle( info );
MsiCloseHandle( patch ); MsiCloseHandle( patch );
msi_free( codes );
return r; return r;
} }
static UINT MSI_ApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szProductCode, LPCWSTR szCommandLine) static UINT MSI_ApplyPatchW(LPCWSTR szPatchPackage, LPCWSTR szProductCode, LPCWSTR szCommandLine)
{ {
UINT r; UINT r, i;
DWORD size; DWORD size;
LPCWSTR cmd_ptr = szCommandLine; LPCWSTR cmd_ptr = szCommandLine;
LPWSTR beg, end, cmd, codes = NULL; LPWSTR cmd, *codes = NULL;
BOOL succeeded = FALSE; BOOL succeeded = FALSE;
static const WCHAR fmt[] = {'%','s',' ','P','A','T','C','H','=','"','%','s','"',0}; 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); r = MsiConfigureProductExW(szProductCode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
else else
{ {
beg = codes; for (i = 0; codes[i]; i++)
while ((end = strchrW(beg, '}')))
{ {
*(end + 1) = '\0'; r = MsiConfigureProductExW(codes[i], INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
r = MsiConfigureProductExW(beg, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, cmd);
if (r == ERROR_SUCCESS) if (r == ERROR_SUCCESS)
{ {
TRACE("patch applied\n"); TRACE("patch applied\n");
succeeded = TRUE; succeeded = TRUE;
} }
beg = end + 2;
} }
if (succeeded) if (succeeded)

View File

@ -958,6 +958,7 @@ extern void msi_feature_set_state(MSIPACKAGE *, MSIFEATURE *, INSTALLSTATE);
extern MSIASSEMBLY *load_assembly(MSIPACKAGE *, MSICOMPONENT *); extern MSIASSEMBLY *load_assembly(MSIPACKAGE *, MSICOMPONENT *);
extern UINT install_assembly(MSIPACKAGE *, MSICOMPONENT *); extern UINT install_assembly(MSIPACKAGE *, MSICOMPONENT *);
extern WCHAR *font_version_from_file(const WCHAR *); extern WCHAR *font_version_from_file(const WCHAR *);
extern WCHAR **msi_split_string(const WCHAR *, WCHAR);
/* media */ /* media */