@joebigelow / wix / commits / d70b0710

WIXFEAT:5355 - Don't clear variable for missing key or value.

Sean Hall committed Nov 1, 2020 at 17:08 UTC d70b0710ba8ae05a5018ce96967f1cf7a7f717f5
2 files changed +8 -4
src/engine/search.cpp
+2 -4
@@ -946,8 +946,7 @@ static HRESULT RegistrySearchValue(
946 {
947 // What if there is a hidden variable in sczKey?
948 LogStringLine(REPORT_STANDARD, "Registry key not found. Key = '%ls'", sczKey);
949 - hr = VariableSetVariant(pVariables, pSearch->sczVariable, &value);
950 - ExitOnFailure(hr, "Failed to clear variable.");
949 +
950 ExitFunction1(hr = S_OK);
951 }
952 ExitOnFailure(hr, "Failed to open registry key.");
@@ -958,8 +957,7 @@ static HRESULT RegistrySearchValue(
957 {
958 // What if there is a hidden variable in sczKey or sczValue?
959 LogStringLine(REPORT_STANDARD, "Registry value not found. Key = '%ls', Value = '%ls'", sczKey, sczValue);
961 - hr = VariableSetVariant(pVariables, pSearch->sczVariable, &value);
962 - ExitOnFailure(hr, "Failed to clear variable.");
960 +
961 ExitFunction1(hr = S_OK);
962 }
963 ExitOnWin32Error(er, hr, "Failed to query registry key value size.");
src/test/BurnUnitTest/SearchTest.cpp
+6
@@ -198,6 +198,8 @@ namespace Bootstrapper
198
199 VariableSetStringHelper(&variables, L"MyKey", L"SOFTWARE\\Microsoft\\WiX_Burn_UnitTest\\Value", FALSE);
200 VariableSetStringHelper(&variables, L"MyValue", L"String", FALSE);
201 + VariableSetStringHelper(&variables, L"Variable27", L"Default27", FALSE);
202 + VariableSetStringHelper(&variables, L"Variable28", L"Default28", FALSE);
203
204 LPCWSTR wzDocument =
205 L"<Bundle>"
@@ -227,6 +229,8 @@ namespace Bootstrapper
229 L" <RegistrySearch Id='Search24' Type='exists' Root='HKU' Key='.DEFAULT\\System\\NetworkServiceSidSubkeyDoesNotExist' Variable='Variable24' />"
230 L" <RegistrySearch Id='Search25' Type='value' Root='HKCR' Key='.msi' Variable='Variable25' VariableType='string' />"
231 L" <RegistrySearch Id='Search26' Type='value' Root='HKCR' Key='.msi' Variable='Variable26' VariableType='formatted' />"
232 + L" <RegistrySearch Id='Search27' Type='value' Root='HKCU' Key='SOFTWARE\\Microsoft\\WiX_Burn_UnitTest\\StringDoesNotExist' Value='String' Variable='Variable27' VariableType='string' />"
233 + L" <RegistrySearch Id='Search28' Type='value' Root='HKCU' Key='SOFTWARE\\Microsoft\\WiX_Burn_UnitTest\\String' Value='DoesNotExist' Variable='Variable28' VariableType='string' />"
234 L"</Bundle>";
235
236 // load XML document
@@ -270,6 +274,8 @@ namespace Bootstrapper
274 Assert::Equal(0ll, VariableGetNumericHelper(&variables, L"Variable24"));
275 Assert::Equal<String^>(gcnew String(L"Msi.Package"), VariableGetStringHelper(&variables, L"Variable25"));
276 Assert::Equal<String^>(gcnew String(L"Msi.Package"), VariableGetStringHelper(&variables, L"Variable26"));
277 + Assert::Equal<String^>(gcnew String(L"Default27"), VariableGetStringHelper(&variables, L"Variable27"));
278 + Assert::Equal<String^>(gcnew String(L"Default28"), VariableGetStringHelper(&variables, L"Variable28"));
279 }
280 finally
281 {