https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2c8f2a099b712334f49ef…
commit 2c8f2a099b712334f49ef0fa11bf56a2b279b13e
Author: Serge Gautherie <32623169+SergeGautherie(a)users.noreply.github.com>
AuthorDate: Fri Nov 29 08:43:15 2019 +0100
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Fri Nov 29 08:43:15 2019 +0100
[OPENGLCFG] general.c: Fix overruns and warnings, improve code consistency (#1923)
* [OPENGLCFG] dwNumDrivers: Fix related pOglDrivers[] overruns
Follow-up to e7b8f273094c9402ff1df3baa5841bf3518a3f02.
* [OPENGLCFG] dwNumDrivers: Sync related iKey to DWORD type
* [OPENGLCFG] Fix 2 MSVC-x64 'C4267' warnings about RegSetValueExW()
---
dll/cpl/openglcfg/general.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/dll/cpl/openglcfg/general.c b/dll/cpl/openglcfg/general.c
index 69170a4232f..3f228da19b9 100644
--- a/dll/cpl/openglcfg/general.c
+++ b/dll/cpl/openglcfg/general.c
@@ -48,14 +48,14 @@ static VOID InitSettings(HWND hWndDlg)
if (dwType == REG_SZ)
{
DWORD ret;
- INT iKey;
+ DWORD iKey;
if (wcsncmp(szBultin, szDriver, MAX_KEY_LENGTH) == 0)
SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_SETCURSEL, RENDERER_RSWR, 0);
ret = RegQueryInfoKeyW(hKeyDrivers, NULL, NULL, NULL, &dwNumDrivers, NULL,
NULL, NULL, NULL, NULL, NULL, NULL);
- if (ret != ERROR_SUCCESS || dwNumDrivers <= 0)
+ if (ret != ERROR_SUCCESS || dwNumDrivers == 0)
{
RegCloseKey(hKeyDrivers);
RegCloseKey(hKeyRenderer);
@@ -139,7 +139,7 @@ static VOID SaveSettings(HWND hWndDlg)
{
WCHAR szBuffer[MAX_KEY_LENGTH];
LoadString(hApplet, IDS_RENDERER_RSWR, (LPTSTR)szBuffer, 127);
- RegSetValueExW(hKeyRenderer, L"", 0, REG_SZ, (PBYTE)szBuffer,
(wcslen(szBuffer) + 1) * sizeof(WCHAR));
+ RegSetValueExW(hKeyRenderer, L"", 0, REG_SZ, (PBYTE)szBuffer,
(DWORD)((wcslen(szBuffer) + 1) * sizeof(WCHAR)));
break;
}
@@ -148,8 +148,8 @@ static VOID SaveSettings(HWND hWndDlg)
/* Adjustment for DEFAULT and RSWR renderers */
iSel -= 2;
- if (iSel >= 0 && iSel <= dwNumDrivers)
- RegSetValueExW(hKeyRenderer, L"", 0, REG_SZ,
(PBYTE)pOglDrivers[iSel], (wcslen(pOglDrivers[iSel]) + 1) * sizeof(WCHAR));
+ if (iSel >= 0 && iSel < dwNumDrivers)
+ RegSetValueExW(hKeyRenderer, L"", 0, REG_SZ,
(PBYTE)pOglDrivers[iSel], (DWORD)((wcslen(pOglDrivers[iSel]) + 1) * sizeof(WCHAR)));
break;
}
@@ -192,8 +192,9 @@ INT_PTR CALLBACK GeneralPageProc(HWND hWndDlg, UINT uMsg, WPARAM
wParam, LPARAM
case WM_DESTROY:
if (pOglDrivers != NULL)
{
- INT iKey;
- for (iKey = 0; iKey <= dwNumDrivers; iKey++)
+ DWORD iKey;
+
+ for (iKey = 0; iKey < dwNumDrivers; ++iKey)
HeapFree(GetProcessHeap(), 0, pOglDrivers[iKey]);
HeapFree(GetProcessHeap(), 0, pOglDrivers);