From 508ce4d9f89858d529a143e713d6450a751d57b2 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sun, 20 Mar 2011 14:28:12 +0000 Subject: [PATCH] [win32k] - Fix disconnecting from a desktop when IntSetThreadDesktop gets NULL parameter svn path=/trunk/; revision=51101 --- .../subsystems/win32/win32k/ntuser/desktop.c | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index f56d587f648..0a240ad7772 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -1798,7 +1798,7 @@ BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure) { - PDESKTOP DesktopObject, OldDesktop; + PDESKTOP DesktopObject = NULL, OldDesktop; HDESK hOldDesktop; PTHREADINFO W32Thread; NTSTATUS Status; @@ -1809,24 +1809,28 @@ IntSetThreadDesktop(IN HDESK hDesktop, MapHeap = (PsGetCurrentProcess() != PsInitialSystemProcess); W32Thread = PsGetCurrentThreadWin32Thread(); - /* Validate the new desktop. */ - Status = IntValidateDesktopHandle( - hDesktop, - UserMode, - 0, - &DesktopObject); - - if (!NT_SUCCESS(Status)) + if(hDesktop != NULL) { - DPRINT("Validation of desktop handle (0x%X) failed\n", hDesktop); - return FALSE; - } + /* Validate the new desktop. */ + Status = IntValidateDesktopHandle( + hDesktop, + UserMode, + 0, + &DesktopObject); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("Validation of desktop handle (0x%X) failed\n", hDesktop); + return FALSE; + } + + if (W32Thread->rpdesk == DesktopObject) + { + /* Nothing to do */ + ObDereferenceObject(DesktopObject); + return TRUE; + } - if (W32Thread->rpdesk == DesktopObject) - { - /* Nothing to do */ - ObDereferenceObject(DesktopObject); - return TRUE; } if (!IsListEmpty(&W32Thread->WindowListHead))