소스 검색

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
Brad King 6 년 전
부모
커밋
a7aade8419
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 4
      Source/cmGlobalVisualStudioGenerator.cxx

+ 4 - 4
Source/cmGlobalVisualStudioGenerator.cxx

@@ -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;
     }