diff --git a/reactos/subsystems/ntvdm/dos/dem.c b/reactos/subsystems/ntvdm/dos/dem.c index f0b251d2e03..a0b1a5baac6 100644 --- a/reactos/subsystems/ntvdm/dos/dem.c +++ b/reactos/subsystems/ntvdm/dos/dem.c @@ -119,8 +119,8 @@ static VOID WINAPI DosCmdInterpreterBop(LPWORD Stack) STARTUPINFOA StartupInfo; PROCESS_INFORMATION ProcessInformation; - /* NULL-terminate the command by removing the return carriage character */ - while (*CmdPtr != '\r') CmdPtr++; + /* NULL-terminate the command line by removing the return carriage character */ + while (*CmdPtr && *CmdPtr != '\r') CmdPtr++; *CmdPtr = '\0'; DPRINT1("CMD Run Command '%s'\n", Command); diff --git a/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c b/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c index 6925c268ce8..353fa6d3c22 100644 --- a/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c +++ b/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c @@ -926,6 +926,10 @@ DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType, return ERROR_NOT_SUPPORTED; } + /* NULL-terminate the command line by removing the return carriage character */ + while (*CommandLine && *CommandLine != '\r') CommandLine++; + *(LPSTR)CommandLine = '\0'; + /* Open a handle to the executable */ FileHandle = CreateFileA(ExecutablePath, GENERIC_READ,