Jelajahi Sumber

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
Brad King 6 tahun lalu
induk
melakukan
f6211f57d6
1 mengubah file dengan 4 tambahan dan 5 penghapusan
  1. 4 5
      Source/cmGlobalVisualStudioGenerator.cxx

+ 4 - 5
Source/cmGlobalVisualStudioGenerator.cxx

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