From 33840923385dcf909548678c0fffa34869263fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 18 May 2014 23:13:12 +0000 Subject: [PATCH] [KERNEL32]: Fix the newline adding (see r63361). svn path=/trunk/; revision=63363 --- reactos/dll/win32/kernel32/client/vdm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/reactos/dll/win32/kernel32/client/vdm.c b/reactos/dll/win32/kernel32/client/vdm.c index ca683838b76..cb2ac243469 100644 --- a/reactos/dll/win32/kernel32/client/vdm.c +++ b/reactos/dll/win32/kernel32/client/vdm.c @@ -284,14 +284,13 @@ BaseCheckVDM(IN ULONG BinaryType, if (StartupInfo->dwFlags & STARTF_USESTDHANDLES) { /* Set the standard handles */ - CheckVdm->StdIn = StartupInfo->hStdInput; + CheckVdm->StdIn = StartupInfo->hStdInput; CheckVdm->StdOut = StartupInfo->hStdOutput; CheckVdm->StdErr = StartupInfo->hStdError; } /* Allocate memory for the ANSI strings */ - - /* For the command line we need to add two characters needed for newline '\r\n' */ + // We need to add the two newline characters '\r\n' to the command line AnsiCmdLine = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CheckVdm->CmdLen + 2); AnsiAppName = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CheckVdm->AppLen); AnsiCurDirectory = (PCHAR)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, CheckVdm->CurDirectoryLen); @@ -325,11 +324,11 @@ BaseCheckVDM(IN ULONG BinaryType, CheckVdm->CmdLen, NULL, NULL); - /* Add a needed newline '\r\n' */ - CheckVdm->CmdLen--; // FIXME.... - AnsiCmdLine[CheckVdm->CmdLen ] = '\r'; - AnsiCmdLine[CheckVdm->CmdLen + 1] = '\n'; - CheckVdm->CmdLen += 2; + /* Add a needed newline '\r\n' and NULL-terminate */ + CheckVdm->CmdLen--; // Rewind back to the NULL character + AnsiCmdLine[CheckVdm->CmdLen++] = '\r'; + AnsiCmdLine[CheckVdm->CmdLen++] = '\n'; + AnsiCmdLine[CheckVdm->CmdLen++] = 0; /* Convert the short application name into an ANSI string */ WideCharToMultiByte(CP_ACP,