James Hawkins : msi: Test and handle the case where the SourceList key does not exist and the PackageName value does not exist in MsiGetProductInfo .
Alexandre Julliard
julliard at winehq.org
Mon Mar 23 12:34:55 CDT 2009
Module: wine
Branch: master
Commit: cb958cd7736f6c0e3a3c3c68bc74ea5531205e02
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cb958cd7736f6c0e3a3c3c68bc74ea5531205e02
Author: James Hawkins <truiken at gmail.com>
Date: Sun Mar 22 14:30:56 2009 -0700
msi: Test and handle the case where the SourceList key does not exist and the PackageName value does not exist in MsiGetProductInfo.
---
dlls/msi/msi.c | 11 +++++++++--
dlls/msi/tests/msi.c | 19 +++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index cb05b64..93220eb 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -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);
}
diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c
index 2b38ea2..6fe6656 100644
--- a/dlls/msi/tests/msi.c
+++ b/dlls/msi/tests/msi.c
@@ -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);
More information about the wine-cvs
mailing list