Module: wine Branch: master Commit: b4a7a30b1853d22c2d91b91e847728bea6c5988d URL: http://source.winehq.org/git/wine.git/?a=commit;h=b4a7a30b1853d22c2d91b91e84...
Author: Hans Leidekker hans@codeweavers.com Date: Mon May 2 16:02:25 2011 +0200
msi: Fix handling of components without a key path in MsiEnumComponentCostsW.
---
dlls/msi/msi.c | 15 ++++++++++++--- dlls/msi/tests/package.c | 15 +++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index 4a79daf..b5e4b13 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -1864,12 +1864,22 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD i
drive[0] = 0; *cost = *temp = 0; + GetWindowsDirectoryW( path, MAX_PATH ); if (component && component[0]) { - *cost = max( 8, comp->Cost / 512 ); if (comp->assembly && !comp->assembly->application) *temp = comp->Cost; - if ((file = get_loaded_file( package, comp->KeyPath ))) + if (!comp->Enabled || !comp->KeyPath) { + *cost = 0; + drive[0] = path[0]; + drive[1] = ':'; + drive[2] = 0; + *buflen = 2; + r = ERROR_SUCCESS; + } + else if ((file = get_loaded_file( package, comp->KeyPath ))) + { + *cost = max( 8, comp->Cost / 512 ); drive[0] = file->TargetPath[0]; drive[1] = ':'; drive[2] = 0; @@ -1880,7 +1890,6 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD i else if (IStorage_Stat( package->db->storage, &stat, STATFLAG_NONAME ) == S_OK) { *temp = max( 8, stat.cbSize.QuadPart / 512 ); - GetWindowsDirectoryW( path, MAX_PATH ); drive[0] = path[0]; drive[1] = ':'; drive[2] = 0; diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index d7161d1..8d70d1c 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -12942,16 +12942,13 @@ static void test_MsiEnumComponentCosts(void) r = add_file_entry( hdb, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" ); ok( r == ERROR_SUCCESS, "cannot add file %u\n", r );
- r = add_file_entry( hdb, "'two.txt', 'two', 'two.txt', 8192, '', '', 8192, 2" ); - ok( r == ERROR_SUCCESS, "cannot add file %u\n", r ); - r = create_component_table( hdb ); ok( r == ERROR_SUCCESS, "cannot create Component table %u\n", r );
r = add_component_entry( hdb, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" ); ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
- r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', 'two.txt'" ); + r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" ); ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
r = create_feature_table( hdb ); @@ -13103,6 +13100,16 @@ static void test_MsiEnumComponentCosts(void) len = sizeof(drive); drive[0] = 0; cost = temp = 0xdead; + r = MsiEnumComponentCostsA( hpkg, "two", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp ); + ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r ); + ok( len == 2, "expected len == 2, got %u\n", len ); + ok( drive[0], "expected a drive\n" ); + ok( !cost, "expected cost == 0, got %d\n", cost ); + ok( !temp, "expected temp == 0, got %d\n", temp ); + + len = sizeof(drive); + drive[0] = 0; + cost = temp = 0xdead; r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp ); ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r ); ok( len == 2, "expected len == 2, got %u\n", len );