msi: Handle a NULL and empty szPackagePath in MsiInstallProduct (Coverity 181).

This commit is contained in:
James Hawkins 2009-03-22 14:31:35 -07:00 committed by Alexandre Julliard
parent fb8db0ac13
commit 5e62686a0f
2 changed files with 21 additions and 0 deletions

View File

@ -231,6 +231,12 @@ UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
TRACE("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
if (!szPackagePath)
return ERROR_INVALID_PARAMETER;
if (!*szPackagePath)
return ERROR_PATH_NOT_FOUND;
r = MSI_OpenPackageW( szPackagePath, &package );
if (r == ERROR_SUCCESS)
{

View File

@ -1721,6 +1721,21 @@ static void test_MsiInstallProduct(void)
return;
}
/* szPackagePath is NULL */
r = MsiInstallProductA(NULL, "INSTALL=ALL");
ok(r == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", r);
/* both szPackagePath and szCommandLine are NULL */
r = MsiInstallProductA(NULL, NULL);
ok(r == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", r);
/* szPackagePath is empty */
r = MsiInstallProductA("", "INSTALL=ALL");
ok(r == ERROR_PATH_NOT_FOUND,
"Expected ERROR_PATH_NOT_FOUND, got %d\n", r);
create_test_files();
create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));