[0.4.10][DESK] Fix GetDC/ReleaseDC error management
authorJoachim Henze <Joachim.Henze@reactos.org>
Mon, 5 Jul 2021 22:50:37 +0000 (00:50 +0200)
committerJoachim Henze <Joachim.Henze@reactos.org>
Mon, 5 Jul 2021 22:50:37 +0000 (00:50 +0200)
Fix missing ReleaseDC related to the spectrum (color depth)

We leaked one device context for each bpp change within the
desk.cpl-session, which gave the following logging when closing desk.cpl:
(win32ss/user/ntuser/windc.c:749) err: [00060138] GetDC() without ReleaseDC()!
1 time for each leak.

Partial backport of (#2707)
Fix picked from 0.4.15-dev-2867-g d635ce0cc0336a9b77d243ddce946876f48ec4f6

dll/cpl/desk/settings.c

index c8d4761..dc59fc9 100644 (file)
@@ -472,8 +472,12 @@ OnBPPChanged(IN HWND hwndDlg, IN PSETTINGS_DATA pData)
     /* Show a new spectrum bitmap */
     hSpectrumControl = GetDlgItem(hwndDlg, IDC_SETTINGS_SPECTRUM);
     hSpectrumDC = GetDC(hSpectrumControl);
+    if (hSpectrumDC == NULL)
+        return;
+
     GetClientRect(hSpectrumControl, &client);
     ShowColorSpectrum(hSpectrumDC, &client, dmNewBitsPerPel, pData);
+    ReleaseDC(hSpectrumControl, hSpectrumDC);
 
     /* Find if new parameters are valid */
     Current = pData->CurrentDisplayDevice->CurrentSettings;