From d70b0710ba8ae05a5018ce96967f1cf7a7f717f5 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 1 Nov 2020 17:08:51 -0600 Subject: WIXFEAT:5355 - Don't clear variable for missing key or value. --- src/engine/search.cpp | 6 ++---- src/test/BurnUnitTest/SearchTest.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/engine/search.cpp b/src/engine/search.cpp index 065003c7..6d5f8d49 100644 --- a/src/engine/search.cpp +++ b/src/engine/search.cpp @@ -946,8 +946,7 @@ static HRESULT RegistrySearchValue( { // What if there is a hidden variable in sczKey? LogStringLine(REPORT_STANDARD, "Registry key not found. Key = '%ls'", sczKey); - hr = VariableSetVariant(pVariables, pSearch->sczVariable, &value); - ExitOnFailure(hr, "Failed to clear variable."); + ExitFunction1(hr = S_OK); } ExitOnFailure(hr, "Failed to open registry key."); @@ -958,8 +957,7 @@ static HRESULT RegistrySearchValue( { // What if there is a hidden variable in sczKey or sczValue? LogStringLine(REPORT_STANDARD, "Registry value not found. Key = '%ls', Value = '%ls'", sczKey, sczValue); - hr = VariableSetVariant(pVariables, pSearch->sczVariable, &value); - ExitOnFailure(hr, "Failed to clear variable."); + ExitFunction1(hr = S_OK); } ExitOnWin32Error(er, hr, "Failed to query registry key value size."); diff --git a/src/test/BurnUnitTest/SearchTest.cpp b/src/test/BurnUnitTest/SearchTest.cpp index d868190d..eca01f5f 100644 --- a/src/test/BurnUnitTest/SearchTest.cpp +++ b/src/test/BurnUnitTest/SearchTest.cpp @@ -198,6 +198,8 @@ namespace Bootstrapper VariableSetStringHelper(&variables, L"MyKey", L"SOFTWARE\\Microsoft\\WiX_Burn_UnitTest\\Value", FALSE); VariableSetStringHelper(&variables, L"MyValue", L"String", FALSE); + VariableSetStringHelper(&variables, L"Variable27", L"Default27", FALSE); + VariableSetStringHelper(&variables, L"Variable28", L"Default28", FALSE); LPCWSTR wzDocument = L"" @@ -227,6 +229,8 @@ namespace Bootstrapper L" " L" " L" " + L" " + L" " L""; // load XML document @@ -270,6 +274,8 @@ namespace Bootstrapper Assert::Equal(0ll, VariableGetNumericHelper(&variables, L"Variable24")); Assert::Equal(gcnew String(L"Msi.Package"), VariableGetStringHelper(&variables, L"Variable25")); Assert::Equal(gcnew String(L"Msi.Package"), VariableGetStringHelper(&variables, L"Variable26")); + Assert::Equal(gcnew String(L"Default27"), VariableGetStringHelper(&variables, L"Variable27")); + Assert::Equal(gcnew String(L"Default28"), VariableGetStringHelper(&variables, L"Variable28")); } finally { -- cgit v1.2.3-55-g6feb