[WINESYNC] msi: Handle some invalid parameters in MsiGetFeatureCost().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 1b6adcb7216a6b4a0706ac7255f3ddb832656127 by Zebediah Figura <z.figura12@gmail.com>
This commit is contained in:
winesync 2022-03-12 15:12:06 +01:00 committed by Mark Jansen
parent 03faa10759
commit 818a84dd11
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
2 changed files with 25 additions and 2 deletions

View file

@ -1061,6 +1061,9 @@ UINT WINAPI MsiGetFeatureCostW(MSIHANDLE hInstall, LPCWSTR szFeature,
TRACE("(%d %s %i %i %p)\n", hInstall, debugstr_w(szFeature),
iCostTree, iState, piCost);
if (!szFeature)
return ERROR_INVALID_PARAMETER;
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
if (!package)
{
@ -1090,6 +1093,12 @@ UINT WINAPI MsiGetFeatureCostW(MSIHANDLE hInstall, LPCWSTR szFeature,
return ERROR_SUCCESS;
}
if (!piCost)
{
msiobj_release( &package->hdr );
return ERROR_INVALID_PARAMETER;
}
feature = msi_get_loaded_feature(package, szFeature);
if (feature)

View file

@ -8479,7 +8479,7 @@ static void test_MsiApplyPatch(void)
ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
}
static void test_MsiEnumComponentCosts(void)
static void test_costs(void)
{
MSIHANDLE hdb, hpkg;
char package[12], drive[3];
@ -8662,6 +8662,20 @@ static void test_MsiEnumComponentCosts(void)
r = MsiEnumComponentCostsA( hpkg, "", 1, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
/* test MsiGetFeatureCost */
cost = 0xdead;
r = MsiGetFeatureCostA( hpkg, NULL, MSICOSTTREE_SELFONLY, INSTALLSTATE_LOCAL, &cost );
ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r);
ok( cost == 0xdead, "got %d\n", cost );
r = MsiGetFeatureCostA( hpkg, "one", MSICOSTTREE_SELFONLY, INSTALLSTATE_LOCAL, NULL );
ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r);
cost = 0xdead;
r = MsiGetFeatureCostA( hpkg, "one", MSICOSTTREE_SELFONLY, INSTALLSTATE_LOCAL, &cost );
ok( !r, "got %u\n", r);
ok( cost == 8, "got %d\n", cost );
MsiCloseHandle( hpkg );
error:
MsiCloseHandle( hdb );
@ -9702,7 +9716,7 @@ START_TEST(package)
test_MsiSetProperty();
test_MsiApplyMultiplePatches();
test_MsiApplyPatch();
test_MsiEnumComponentCosts();
test_costs();
test_MsiDatabaseCommit();
test_externalui();
test_externalui_message();