https://git.reactos.org/?p=reactos.git;a=commitdiff;h=abb75b621472646b4bc06…
commit abb75b621472646b4bc06f11e05c012358c85f35
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Mon Dec 26 16:11:14 2022 +0100
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Wed Jan 4 10:32:28 2023 +0100
[WIN32K] Add some NULL checks for THREADINFO::rpdesk
rpdesk should probably never be NULL, but it happens in rare circumstances, like csrss
being terminated.
---
win32ss/user/ntuser/desktop.c | 8 ++++++++
win32ss/user/ntuser/window.c | 2 +-
win32ss/user/ntuser/winpos.c | 4 ++--
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/win32ss/user/ntuser/desktop.c b/win32ss/user/ntuser/desktop.c
index 2344fea0c01..16b7aa0b8c2 100644
--- a/win32ss/user/ntuser/desktop.c
+++ b/win32ss/user/ntuser/desktop.c
@@ -1788,6 +1788,14 @@ BOOL IntDeRegisterShellHookWindow(HWND hWnd)
PLIST_ENTRY ListEntry;
PSHELL_HOOK_WINDOW Current;
+ // FIXME: This probably shouldn't happen, but it does
+ if (Desktop == NULL)
+ {
+ Desktop = IntGetActiveDesktop();
+ if (Desktop == NULL)
+ return FALSE;
+ }
+
ListEntry = Desktop->ShellHookWindows.Flink;
while (ListEntry != &Desktop->ShellHookWindows)
{
diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c
index 691b3f2996c..1c2b0474c08 100644
--- a/win32ss/user/ntuser/window.c
+++ b/win32ss/user/ntuser/window.c
@@ -493,7 +493,7 @@ static void IntSendDestroyMsg(HWND hWnd)
}
/* If the window being destroyed is currently tracked... */
- if (ti->rpdesk->spwndTrack == Window)
+ if (ti->rpdesk && ti->rpdesk->spwndTrack == Window)
{
IntRemoveTrackMouseEvent(ti->rpdesk);
}
diff --git a/win32ss/user/ntuser/winpos.c b/win32ss/user/ntuser/winpos.c
index 79e29730f1e..f9ce2583b87 100644
--- a/win32ss/user/ntuser/winpos.c
+++ b/win32ss/user/ntuser/winpos.c
@@ -436,12 +436,12 @@ co_WinPosActivateOtherWindow(PWND Wnd)
// Find any window to bring to top. Works Okay for wine since it does not see X11
windows.
WndTo = UserGetDesktopWindow();
- WndTo = WndTo->spwndChild;
- if ( WndTo == NULL )
+ if ((WndTo == NULL) || (WndTo->spwndChild == NULL))
{
//ERR("WinPosActivateOtherWindow No window!\n");
return;
}
+ WndTo = WndTo->spwndChild;
for (;;)
{
if (WndTo == Wnd)