From 3eee408cac2cd5e8526c3c0168960dc46d381097 Mon Sep 17 00:00:00 2001 From: cutealien Date: Fri, 13 May 2022 15:03:27 +0000 Subject: [PATCH] Avoid potential call to GetProcAddress with 0 for HMODULE Found by VS code analyser git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6394 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CIrrDeviceWin32.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp index 631f670f..2ef6f012 100644 --- a/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/source/Irrlicht/CIrrDeviceWin32.cpp @@ -1529,7 +1529,6 @@ typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD); void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) { OSVERSIONINFOEX osvi; - PGPI pGPI; BOOL bOsVersionInfoEx; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); @@ -1581,9 +1580,14 @@ void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) { if (osvi.dwMajorVersion == 6) { - DWORD dwType; - pGPI = (PGPI)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo"); - pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType); + DWORD dwType = PRODUCT_UNDEFINED; + HMODULE hmKernel32 = GetModuleHandle(TEXT("kernel32.dll")); + if ( hmKernel32 ) + { + PGPI pGPI = (PGPI)GetProcAddress(hmKernel32, "GetProductInfo"); + if ( pGPI ) + pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType); + } switch (dwType) {