From 270998174c624a2b27cf38fe688cf6b18493a6d4 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Fri, 15 Apr 2016 20:43:25 +0000 Subject: [PATCH] [WIN32K:NTUSER] - Don't access WindowStationName after free - Handle RtlCreateAtomTable failure svn path=/trunk/; revision=71165 --- reactos/win32ss/user/ntuser/winsta.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/reactos/win32ss/user/ntuser/winsta.c b/reactos/win32ss/user/ntuser/winsta.c index 4ab17030dfe..97116588e3c 100644 --- a/reactos/win32ss/user/ntuser/winsta.c +++ b/reactos/win32ss/user/ntuser/winsta.c @@ -454,7 +454,7 @@ NtUserCreateWindowStation( if (!NT_SUCCESS(Status)) { - ERR("ObCreateObject failed for window station %wZ\n", &WindowStationName); + ERR("ObCreateObject failed with %lx for window station %wZ\n", Status, &WindowStationName); ExFreePoolWithTag(WindowStationName.Buffer, TAG_STRING); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return 0; @@ -464,9 +464,16 @@ NtUserCreateWindowStation( RtlZeroMemory(WindowStationObject, sizeof(WINSTATION_OBJECT)); InitializeListHead(&WindowStationObject->DesktopListHead); - Status = RtlCreateAtomTable(37, &WindowStationObject->AtomTable); WindowStationObject->Name = WindowStationName; WindowStationObject->dwSessionId = NtCurrentPeb()->SessionId; + Status = RtlCreateAtomTable(37, &WindowStationObject->AtomTable); + if (!NT_SUCCESS(Status)) + { + ERR("RtlCreateAtomTable failed with %lx for window station %wZ\n", Status, &WindowStationName); + ObDereferenceObject(WindowStationObject); + SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); + return 0; + } Status = ObInsertObject((PVOID)WindowStationObject, NULL, @@ -477,7 +484,7 @@ NtUserCreateWindowStation( if (!NT_SUCCESS(Status)) { - ERR("ObInsertObject failed for window station %wZ\n", &WindowStationName); + ERR("ObInsertObject failed with %lx for window station\n", Status); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return 0; }