From 9e1301c88e6a2f6c1fa7e89a6da630fae74f37ed Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 24 Apr 2009 13:34:55 -0500 Subject: [PATCH] gdiplus: don't leak a device context when GdipCreateFromHWND fails --- dlls/gdiplus/graphics.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index af3968c..36cb324 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -941,11 +941,17 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics) { GpStatus ret; + HDC hdc; TRACE("(%p, %p)\n", hwnd, graphics); - if((ret = GdipCreateFromHDC(GetDC(hwnd), graphics)) != Ok) + hdc = GetDC(hwnd); + + if((ret = GdipCreateFromHDC(hdc, graphics)) != Ok) + { + ReleaseDC(hwnd, hdc); return ret; + } (*graphics)->hwnd = hwnd; (*graphics)->owndc = TRUE; -- 1.5.4.3