msi: Test and handle the case where the SourceList key does not exist and the PackageName value does not exist in MsiGetProductInfo.
This commit is contained in:
parent
dc50773c28
commit
cb958cd773
|
@ -791,8 +791,15 @@ static UINT MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
|
|||
if (!lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGENAMEW))
|
||||
{
|
||||
res = RegOpenKeyW(prodkey, sourcelist, &source);
|
||||
if (res == ERROR_SUCCESS)
|
||||
val = msi_reg_get_value(source, szAttribute, &type);
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
r = ERROR_UNKNOWN_PRODUCT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
val = msi_reg_get_value(source, szAttribute, &type);
|
||||
if (!val)
|
||||
val = empty;
|
||||
|
||||
RegCloseKey(source);
|
||||
}
|
||||
|
|
|
@ -3649,12 +3649,31 @@ static void test_MsiGetProductInfo(void)
|
|||
ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
|
||||
ok(sz == 2, "Expected 2, got %d\n", sz);
|
||||
|
||||
/* SourceList key does not exist */
|
||||
sz = MAX_PATH;
|
||||
lstrcpyA(buf, "apple");
|
||||
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
|
||||
ok(r == ERROR_UNKNOWN_PRODUCT,
|
||||
"Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
|
||||
ok(!lstrcmpA(buf, "apple"),
|
||||
"Expected buf to be unchanged, got \"%s\"\n", buf);
|
||||
ok(sz == MAX_PATH, "Expected sz to be unchanged, got %d\n", sz);
|
||||
|
||||
res = RegCreateKeyA(prodkey, "SourceList", &source);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
/* SourceList key exists, but PackageName val does not exist */
|
||||
sz = MAX_PATH;
|
||||
lstrcpyA(buf, "apple");
|
||||
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
|
||||
ok(sz == 0, "Expected 0, got %d\n", sz);
|
||||
|
||||
res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
/* PackageName val exists */
|
||||
sz = MAX_PATH;
|
||||
lstrcpyA(buf, "apple");
|
||||
r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAME, buf, &sz);
|
||||
|
|
Loading…
Reference in New Issue