From 1f933c38fc644ce03416618a16287e6cb9d5f620 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sun, 28 Sep 2014 17:27:54 +0000 Subject: [PATCH] [NTVDM] Fix the calculation of TotalSize in DosCopyEnvironmentBlock. Return the correct error code in DosLoadExecutable. svn path=/trunk/; revision=64368 --- reactos/subsystems/ntvdm/dos/dos32krnl/dos.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c b/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c index a9aa39d6e52..f3e73fdef03 100644 --- a/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c +++ b/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c @@ -419,6 +419,9 @@ static WORD DosCopyEnvironmentBlock(LPCVOID Environment, LPCSTR ProgramName) /* Add the string buffer size */ TotalSize += strlen(ProgramName) + 1; + /* Add the two extra bytes */ + TotalSize += 2; + /* Allocate the memory for the environment block */ DestSegment = DosAllocateMemory((WORD)((TotalSize + 0x0F) >> 4), NULL); if (!DestSegment) return 0; @@ -1012,7 +1015,7 @@ DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType, /* Check if at least the lowest allocation was successful */ if (Segment == 0) { - Result = ERROR_NOT_ENOUGH_MEMORY; + Result = DosLastError; goto Cleanup; } @@ -1081,7 +1084,7 @@ DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType, Segment = DosAllocateMemory(MaxAllocSize, NULL); if (Segment == 0) { - Result = ERROR_ARENA_TRASHED; + Result = DosLastError; goto Cleanup; } -- 2.17.1