Author: rharabien
Date: Tue Nov 22 18:49:40 2011
New Revision: 54475
URL:
http://svn.reactos.org/svn/reactos?rev=54475&view=rev
Log:
[WIN32CSR]
- Fix process reference leak in case of GuiConsoleOpenUserRegistryPathPerProcessId failing
to open registry key. Fixes console processes in LiveCD being ghosts.
Modified:
trunk/reactos/subsystems/win32/csrss/win32csr/console.c
trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
trunk/reactos/subsystems/win32/csrss/win32csr/handle.c
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/console.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/console.c [iso-8859-1] Tue Nov 22
18:49:40 2011
@@ -140,7 +140,7 @@
GuiMode = TRUE;
}
}
- if (GuiMode)
+ else /* GuiMode */
{
Status = GuiInitConsole(Console, ShowCmd);
if (! NT_SUCCESS(Status))
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] Tue Nov 22
18:49:40 2011
@@ -215,8 +215,8 @@
if (!GetTokenInformation(hProcessToken, TokenUser, (PVOID)Buffer, sizeof(Buffer),
&Length))
{
DPRINT("Error: GetTokenInformation failed(0x%x)\n",GetLastError());
+ CloseHandle(hProcessToken);
CloseHandle(hProcess);
- CloseHandle(hProcessToken);
return FALSE;
}
@@ -224,6 +224,8 @@
if (!NT_SUCCESS(RtlConvertSidToUnicodeString(&SidName, TokUser, TRUE)))
{
DPRINT("Error: RtlConvertSidToUnicodeString failed(0x%x)\n",
GetLastError());
+ CloseHandle(hProcessToken);
+ CloseHandle(hProcess);
return FALSE;
}
@@ -231,15 +233,18 @@
RtlFreeUnicodeString(&SidName);
CloseHandle(hProcessToken);
+ if (res != ERROR_SUCCESS)
+ {
+ CloseHandle(hProcess);
+ return FALSE;
+ }
+
if (hProcHandle)
*hProcHandle = hProcess;
else
CloseHandle(hProcess);
- if (res != ERROR_SUCCESS)
- return FALSE;
- else
- return TRUE;
+ return TRUE;
}
static BOOL
@@ -285,7 +290,7 @@
if (!fLength)
{
- DPRINT("GetProcessImageFileNameW failed(0x%x)ProcessId %d\n",
GetLastError(),hProcess);
+ DPRINT("GetProcessImageFileNameW failed(0x%x)ProcessId %d\n",
GetLastError(), ProcessId);
return FALSE;
}
/*
@@ -2310,7 +2315,7 @@
NULL);
if (NULL == ThreadHandle)
{
- NtClose(GraphicsStartupEvent);
+ CloseHandle(GraphicsStartupEvent);
DPRINT1("Win32Csr: Failed to create graphics console thread. Expect
problems\n");
return STATUS_UNSUCCESSFUL;
}
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/handle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] Tue Nov 22
18:49:40 2011
@@ -158,6 +158,8 @@
LeaveCriticalSection(&Console->Lock);
if (_InterlockedDecrement(&Console->ReferenceCount) == 0)
ConioDeleteConsole(&Console->Header);
+ CloseHandle(ProcessData->ConsoleEvent);
+ ProcessData->ConsoleEvent = NULL;
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
return STATUS_SUCCESS;
}