cmGlobalVisualStudioGenerator: Fix buffer sizes used RegQueryValueExW

In commit 0b9906c2fb (Windows: Use wide-character system APIs,
2013-12-04, v3.0.0-rc1~254^2) several buffer size computations had to be
updated to multiply by `sizeof(wchar_t)`, but some for RegQueryValueExW
were incorrect because the number of bytes was already computed.

Issue: #19610
This commit is contained in:
Brad King
2019-08-21 15:03:56 -04:00
parent 130dbe4a5d
commit f6211f57d6

View File

@@ -572,8 +572,8 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
if (ERROR_SUCCESS == result) {
DWORD valueType = REG_SZ;
wchar_t data1[256];
DWORD cch_data1 = sizeof(data1) * sizeof(data1[0]);
RegQueryValueExW(hsubkey, L"Path", 0, &valueType, (LPBYTE)&data1[0],
DWORD cch_data1 = sizeof(data1);
RegQueryValueExW(hsubkey, L"Path", 0, &valueType, (LPBYTE)data1,
&cch_data1);
DWORD data2 = 0;
@@ -649,9 +649,8 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
if (ERROR_SUCCESS == result) {
DWORD valueType = REG_SZ;
wchar_t data1[256];
DWORD cch_data1 = sizeof(data1) * sizeof(data1[0]);
RegQueryValueExW(hkey, L"Path", 0, &valueType, (LPBYTE)&data1[0],
&cch_data1);
DWORD cch_data1 = sizeof(data1);
RegQueryValueExW(hkey, L"Path", 0, &valueType, (LPBYTE)data1, &cch_data1);
DWORD data2 = 0;
DWORD cch_data2 = sizeof(data2);