From 1b346fdad3c62b21fa9021274889db31a1dbcb3e Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 9 Jan 2010 06:16:51 +0000 Subject: [PATCH] [User32] - Add corrected behavior for SetWindowRgn, delete region object after setting windows region. See bug 4980. - After a successful call to SetWindowRgn, the system owns the region specified by the region handle hRgn. The system does not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do not delete this region handle. The system deletes the region handle when it no longer needed. - References : http://msdn.microsoft.com/en-us/library/dd145102(VS.85).aspx svn path=/trunk/; revision=45013 --- reactos/dll/win32/user32/windows/paint.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/user32/windows/paint.c b/reactos/dll/win32/user32/windows/paint.c index cf2de87c11e..62095932b69 100644 --- a/reactos/dll/win32/user32/windows/paint.c +++ b/reactos/dll/win32/user32/windows/paint.c @@ -149,7 +149,13 @@ SetWindowRgn( Hook = BeginIfHookedUserApiHook(); /* Bypass SEH and go direct. */ - if (!Hook) return (int)NtUserSetWindowRgn(hWnd, hRgn, bRedraw); + if (!Hook) + { + Ret = NtUserSetWindowRgn(hWnd, hRgn, bRedraw); + if (hRgn && Ret) + DeleteObject(hRgn); + return Ret; + } _SEH2_TRY {