[WIN32K:NTUSER] ValidateHwndNoErr: Fix window handle validation (#4981)
authorThamatip Chitpong <tangaming123456@outlook.com>
Sun, 22 Jan 2023 14:44:52 +0000 (21:44 +0700)
committerGitHub <noreply@github.com>
Sun, 22 Jan 2023 14:44:52 +0000 (17:44 +0300)
Also check window state. Addendum to 4d48b88b.

win32ss/user/ntuser/window.c

index 1c2b047..2bdc64f 100644 (file)
@@ -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 */