[COMCTL32] Don't leak memory in PB_ThemedPaint()
authorPierre Schweitzer <pierre@reactos.org>
Fri, 16 Nov 2018 20:22:50 +0000 (21:22 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Fri, 16 Nov 2018 21:07:08 +0000 (22:07 +0100)
CID 1441373

dll/win32/comctl32/button.c

index 813aa74..6a0a226 100644 (file)
@@ -1841,6 +1841,9 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, Bu
     {
         DrawThemeText(theme, hDC, BP_PUSHBUTTON, state, text, lstrlenW(text), dtFlags, 0, &textRect);
         heap_free(text);
+#ifdef __REACTOS__
+        text = NULL;
+#endif
     }
 
     if (focused)
@@ -1862,6 +1865,7 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, Bu
     if (cdrf == CDRF_NOTIFYPOSTPAINT)
         BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTPAINT, &bgRect);
 cleanup:
+    if (text) heap_free(text);
 #endif
     if (hPrevFont) SelectObject(hDC, hPrevFont);
 }