From d2fa38f67a50ecae4e9286516445155690e38ebd Mon Sep 17 00:00:00 2001 From: Gregor Schneider Date: Tue, 18 Aug 2009 13:47:02 +0000 Subject: [PATCH] - GetConsoleAliasW: Check for invalid target buffer, failed memory allocation + set last error svn path=/trunk/; revision=42765 --- reactos/dll/win32/kernel32/misc/console.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/reactos/dll/win32/kernel32/misc/console.c b/reactos/dll/win32/kernel32/misc/console.c index c129edd1934..6e6f57c1ddf 100644 --- a/reactos/dll/win32/kernel32/misc/console.c +++ b/reactos/dll/win32/kernel32/misc/console.c @@ -352,6 +352,12 @@ GetConsoleAliasW(LPWSTR lpSource, DPRINT("GetConsoleAliasW entered lpSource %S lpExeName %S\n", lpSource, lpExeName); + if (lpTargetBuffer == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIAS, CSR_CONSOLE); ExeLength = wcslen(lpExeName) + 1; @@ -361,11 +367,17 @@ GetConsoleAliasW(LPWSTR lpSource, RequestLength = Size + sizeof(CSR_API_MESSAGE); Request = RtlAllocateHeap(GetProcessHeap(), 0, RequestLength); + if (Request == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } CaptureBuffer = CsrAllocateCaptureBuffer(1, TargetBufferLength); if (!CaptureBuffer) { RtlFreeHeap(GetProcessHeap(), 0, Request); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; }