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>
This commit is contained in:
Zebediah Figura 2018-04-24 22:27:41 -05:00 committed by Alexandre Julliard
parent 0fc1b6f2f3
commit 1b6adcb721
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();