cmGlobalVisualStudioGenerator: Fix buffer sizes used with RegEnumKeyExW

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 for RegEnumKeyExW we were
already computing the correct number of characters with a division which
was accidentally converted to a multiplication.  Use `cm::size` to
compute the number of characters in the buffer instead.

Issue: #19610
This commit is contained in:
Brad King
2019-08-21 15:03:56 -04:00
parent f6211f57d6
commit a7aade8419
+4 -4
View File
@@ -556,9 +556,9 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
if (ERROR_SUCCESS == result) {
// Iterate the subkeys and look for the values of interest in each subkey:
wchar_t subkeyname[256];
DWORD cch_subkeyname = sizeof(subkeyname) * sizeof(subkeyname[0]);
DWORD cch_subkeyname = cm::size(subkeyname);
wchar_t keyclass[256];
DWORD cch_keyclass = sizeof(keyclass) * sizeof(keyclass[0]);
DWORD cch_keyclass = cm::size(keyclass);
FILETIME lastWriteTime;
lastWriteTime.dwHighDateTime = 0;
lastWriteTime.dwLowDateTime = 0;
@@ -621,8 +621,8 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
}
++index;
cch_subkeyname = sizeof(subkeyname) * sizeof(subkeyname[0]);
cch_keyclass = sizeof(keyclass) * sizeof(keyclass[0]);
cch_subkeyname = cm::size(subkeyname);
cch_keyclass = cm::size(keyclass);
lastWriteTime.dwHighDateTime = 0;
lastWriteTime.dwLowDateTime = 0;
}