From 0db63068ace2d9f80d79376d685d937b548aedbd Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Mon, 8 May 2017 08:29:17 +0000 Subject: [PATCH] [USER32] - Avoid a memory leak in User32EnumWindows in case the window count is zero. CORE-13194 svn path=/trunk/; revision=74497 --- reactos/win32ss/user/user32/windows/window.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/reactos/win32ss/user/user32/windows/window.c b/reactos/win32ss/user/user32/windows/window.c index 4c79dcc91c7..75dc96e616e 100644 --- a/reactos/win32ss/user/user32/windows/window.c +++ b/reactos/win32ss/user/user32/windows/window.c @@ -674,6 +674,14 @@ User32EnumWindows(HDESK hDesktop, if (!NT_SUCCESS(Status)) return FALSE; + if (!dwCount) + { + if (!dwThreadId) + return FALSE; + else + return TRUE; + } + /* allocate buffer to receive HWND handles */ hHeap = GetProcessHeap(); pHwnd = HeapAlloc(hHeap, 0, sizeof(HWND)*(dwCount+1)); @@ -698,14 +706,6 @@ User32EnumWindows(HDESK hDesktop, return FALSE; } - if (!dwCount) - { - if (!dwThreadId) - return FALSE; - else - return TRUE; - } - /* call the user's callback function until we're done or they tell us to quit */ for ( i = 0; i < dwCount; i++ ) -- 2.17.1