[WIN32K:NTUSER]
authorThomas Faber <thomas.faber@reactos.org>
Fri, 15 Apr 2016 20:24:44 +0000 (20:24 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Fri, 15 Apr 2016 20:24:44 +0000 (20:24 +0000)
- Initialize the window station object before calling ObInsertObject, since the object will be deleted in case of failure.
CORE-11124

svn path=/trunk/; revision=71164

reactos/win32ss/user/ntuser/winsta.c

index fedacf5..4ab1703 100644 (file)
@@ -460,6 +460,14 @@ NtUserCreateWindowStation(
         return 0;
     }
 
+    /* Initialize the window station */
+    RtlZeroMemory(WindowStationObject, sizeof(WINSTATION_OBJECT));
+
+    InitializeListHead(&WindowStationObject->DesktopListHead);
+    Status = RtlCreateAtomTable(37, &WindowStationObject->AtomTable);
+    WindowStationObject->Name = WindowStationName;
+    WindowStationObject->dwSessionId = NtCurrentPeb()->SessionId;
+
     Status = ObInsertObject((PVOID)WindowStationObject,
                             NULL,
                             dwDesiredAccess,
@@ -470,20 +478,10 @@ NtUserCreateWindowStation(
     if (!NT_SUCCESS(Status))
     {
         ERR("ObInsertObject failed for window station %wZ\n", &WindowStationName);
-        ExFreePoolWithTag(WindowStationName.Buffer, TAG_STRING);
         SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
-        ObDereferenceObject(WindowStationObject);
         return 0;
     }
 
-    /* Initialize the window station */
-    RtlZeroMemory(WindowStationObject, sizeof(WINSTATION_OBJECT));
-
-    InitializeListHead(&WindowStationObject->DesktopListHead);
-    Status = RtlCreateAtomTable(37, &WindowStationObject->AtomTable);
-    WindowStationObject->Name = WindowStationName;
-    WindowStationObject->dwSessionId = NtCurrentPeb()->SessionId;
-
     if (InputWindowStation == NULL)
     {
         ERR("Initializing input window station\n");