https://git.reactos.org/?p=reactos.git;a=commitdiff;h=74c45e0975fe9d070ef0b0903354a57357649d84

commit 74c45e0975fe9d070ef0b0903354a57357649d84
Author:     Thamatip Chitpong <tangaming123...@outlook.com>
AuthorDate: Sun Jan 22 21:44:52 2023 +0700
Commit:     GitHub <nore...@github.com>
CommitDate: Sun Jan 22 17:44:52 2023 +0300

    [WIN32K:NTUSER] ValidateHwndNoErr: Fix window handle validation (#4981)
    
    Also check window state. Addendum to 4d48b88b.
---
 win32ss/user/ntuser/window.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c
index 1c2b0474c08..2bdc64f6be9 100644
--- a/win32ss/user/ntuser/window.c
+++ b/win32ss/user/ntuser/window.c
@@ -117,8 +117,16 @@ PWND FASTCALL VerifyWnd(PWND pWnd)
 
 PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
 {
-   if (hWnd) return (PWND)UserGetObjectNoErr(gHandleTable, hWnd, TYPE_WINDOW);
-   return NULL;
+    PWND Window;
+
+    if (!hWnd)
+        return NULL;
+
+    Window = (PWND)UserGetObjectNoErr(gHandleTable, hWnd, TYPE_WINDOW);
+    if (!Window || (Window->state & WNDS_DESTROYED))
+        return NULL;
+
+    return Window;
 }
 
 /* Temp HACK */

Reply via email to