From 71322ef36142570edc94c361ceb21f770303aceb Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sun, 8 May 2022 21:35:05 +0800 Subject: Windows QPA: Fix crash in some rare cases For the WM_SETTINGCHANGE message, lParam sometimes may be NULL [1] and that will lead to crash without extra safe guard. Amends commit qtbase/1ed449e168af133184633d174fd7339a13d1d595 [1] https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-settingchange Change-Id: Ibd1e94b4c1d7882db0719c31a66a5fcc9299c3bd Reviewed-by: Nodir Temirkhodjaev Reviewed-by: Friedemann Kleint Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/windows/qwindowscontext.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/windows/qwindowscontext.cpp') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a5963de478..6bce851aac 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1138,7 +1138,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::SettingChangedEvent: { QWindowsWindow::settingsChanged(); // Only refresh the window theme if the user changes the personalize settings. - if (wParam == 0 && wcscmp(reinterpret_cast(lParam), L"ImmersiveColorSet") == 0) { + if ((wParam == 0) && (lParam != 0) // lParam sometimes may be NULL. + && (wcscmp(reinterpret_cast(lParam), L"ImmersiveColorSet") == 0)) { const bool darkMode = QWindowsTheme::queryDarkMode(); if (darkMode != QWindowsContextPrivate::m_darkMode) { QWindowsContextPrivate::m_darkMode = darkMode; -- cgit v1.2.3