Fix nullptr regression in RegistryUtil::ReadRegistry
authorMichael Schuster <michael@schuster.ms>
Tue, 9 Jun 2020 14:17:04 +0000 (16:17 +0200)
committerKevin Ottens <ervin@ipsquad.net>
Tue, 9 Jun 2020 16:34:43 +0000 (18:34 +0200)
Merging PR #2057 caused the Windows build to fail:

shell_integration\windows\OCUtil\RegistryUtil.cpp(43): error C2664: 'LSTATUS RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY)': cannot convert argument 3 from 'nullptr' to 'DWORD'

The previous implementation prior the PR supplied NULL as the argument 3 to RegOpenKeyEx,
so it was silently accepted and translated to zero, satisfying the DWORD's type requirement.

Signed-off-by: Michael Schuster <michael@schuster.ms>
shell_integration/windows/OCUtil/RegistryUtil.cpp

index fc8b125dc350797e0f8910dc01d7f21f78430815..29a8c89030f02e965e3a225f351a2df3d29bb8ae 100644 (file)
@@ -40,7 +40,7 @@ bool RegistryUtil::ReadRegistry(const wchar_t* key, const wchar_t* name, wstring
 
     HKEY rootKey = nullptr;
 
-    hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CURRENT_USER, (LPCWSTR)key, nullptr, KEY_READ, &rootKey));
+    hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CURRENT_USER, (LPCWSTR)key, 0, KEY_READ, &rootKey));
 
     if(!SUCCEEDED(hResult))
     {