]> repos.lx-s.de Git - winmute.git/commitdiff
Fixed possible crash in LogDialog (if WM_SIZE happens before init)
authorlx-s <lx-s@users.noreply.github.com>
Wed, 8 Jul 2026 08:40:10 +0000 (10:40 +0200)
committerlx-s <lx-s@users.noreply.github.com>
Wed, 8 Jul 2026 08:40:10 +0000 (10:40 +0200)
WinMute/LogDialog.cpp

index da3f0307f52660028351d33599dc514ea89158ec..251182dcf7edeb5d8ea25077e3f4fd2a20fe6e53 100644 (file)
@@ -87,6 +87,10 @@ INT_PTR CALLBACK LogDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
       return 0;
    case WM_SIZE:
       {
+      // WM_SIZE arrives before WM_INITDIALOG, when dlgData is not set yet
+      if (dlgData == nullptr) {
+         return 0;
+      }
       RECT rcClient;
       GetClientRect(hDlg, &rcClient);
       SetWindowPos(
@@ -102,7 +106,7 @@ INT_PTR CALLBACK LogDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
    case WM_LOG_UPDATED: {
       const WMLog &wmLog = WMLog::GetInstance();
       auto logMsg = reinterpret_cast<LogMessage*>(lParam);
-      if (logMsg == nullptr) {
+      if (dlgData == nullptr || logMsg == nullptr) {
          return FALSE;
       }
       const auto formattedMsg = wmLog.FormatLogMessage(*logMsg, true);