msi: Fix some possible NULL pointer dereferences (Coverity).

This commit is contained in:
Mike McCormack 2006-04-17 18:17:52 +09:00 committed by Alexandre Julliard
parent 13dccd7541
commit a92fe55cce
4 changed files with 25 additions and 0 deletions

View File

@ -667,6 +667,9 @@ INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
TRACE("%s\n", debugstr_w(szProduct)); TRACE("%s\n", debugstr_w(szProduct));
if (!szProduct)
return INSTALLSTATE_INVALIDARG;
rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE); rc = MSIREG_OpenUserProductsKey(szProduct,&hkey,FALSE);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto end; goto end;

View File

@ -514,6 +514,9 @@ UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phP
TRACE("%s %08lx %p\n", debugstr_w(szPackage), dwOptions, phPackage ); TRACE("%s %08lx %p\n", debugstr_w(szPackage), dwOptions, phPackage );
if( szPackage == NULL )
return ERROR_INVALID_PARAMETER;
if( dwOptions ) if( dwOptions )
FIXME("dwOptions %08lx not supported\n", dwOptions); FIXME("dwOptions %08lx not supported\n", dwOptions);

View File

@ -675,6 +675,9 @@ UINT WINAPI MsiEnumFeaturesW(LPCWSTR szProduct, DWORD index,
TRACE("%s %ld %p %p\n",debugstr_w(szProduct),index,szFeature,szParent); TRACE("%s %ld %p %p\n",debugstr_w(szProduct),index,szFeature,szParent);
if( !szProduct )
return ERROR_INVALID_PARAMETER;
r = MSIREG_OpenFeaturesKey(szProduct,&hkeyProduct,FALSE); r = MSIREG_OpenFeaturesKey(szProduct,&hkeyProduct,FALSE);
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS )
return ERROR_NO_MORE_ITEMS; return ERROR_NO_MORE_ITEMS;

View File

@ -66,6 +66,21 @@ static void test_usefeature(void)
} }
static void test_null(void)
{
MSIHANDLE hpkg;
UINT r;
r = MsiOpenPackageExW(NULL, 0, &hpkg);
ok( r == ERROR_INVALID_PARAMETER,"wrong error");
r = MsiQueryProductStateW(NULL);
ok( r == INSTALLSTATE_INVALIDARG, "wrong return\n");
r = MsiEnumFeaturesW(NULL,0,NULL,NULL);
ok( r == ERROR_INVALID_PARAMETER,"wrong error");
}
START_TEST(msi) START_TEST(msi)
{ {
HMODULE hmod = GetModuleHandle("msi.dll"); HMODULE hmod = GetModuleHandle("msi.dll");
@ -73,4 +88,5 @@ START_TEST(msi)
GetProcAddress(hmod, "MsiUseFeatureExA"); GetProcAddress(hmod, "MsiUseFeatureExA");
test_usefeature(); test_usefeature();
test_null();
} }