[ros-diffs] [gadamopoulos] 51101: [win32k] - Fix disconnecting from a desktop when IntSetThreadDesktop gets NULL parameter

gadamopoulos at svn.reactos.org gadamopoulos at svn.reactos.org
Sun Mar 20 14:28:13 UTC 2011


Author: gadamopoulos
Date: Sun Mar 20 14:28:12 2011
New Revision: 51101

URL: http://svn.reactos.org/svn/reactos?rev=51101&view=rev
Log:
[win32k]
- Fix disconnecting from a desktop when IntSetThreadDesktop gets NULL parameter

Modified:
    trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c?rev=51101&r1=51100&r2=51101&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] Sun Mar 20 14:28:12 2011
@@ -1798,7 +1798,7 @@
 IntSetThreadDesktop(IN HDESK hDesktop,
                     IN BOOL FreeOnFailure)
 {
-    PDESKTOP DesktopObject, OldDesktop;
+    PDESKTOP DesktopObject = NULL, OldDesktop;
     HDESK hOldDesktop;
     PTHREADINFO W32Thread;
     NTSTATUS Status;
@@ -1809,24 +1809,28 @@
     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;
-    }
-
-    if (W32Thread->rpdesk == DesktopObject)
-    {
-        /* Nothing to do */
-        ObDereferenceObject(DesktopObject);
-        return TRUE;
+        /* 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 (!IsListEmpty(&W32Thread->WindowListHead))




More information about the Ros-diffs mailing list