From 87fc3759e308f96da813f13d7d08e3da49812814 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Mon, 22 Jul 2013 16:36:05 +0000 Subject: [PATCH] [NTVDM] Fix bug while initializing and copying the environment strings. svn path=/branches/ntvdm/; revision=59557 --- subsystems/ntvdm/dos.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/subsystems/ntvdm/dos.c b/subsystems/ntvdm/dos.c index afdb59550da..d6a9d2f9439 100644 --- a/subsystems/ntvdm/dos.c +++ b/subsystems/ntvdm/dos.c @@ -83,8 +83,8 @@ static WORD DosCopyEnvironmentBlock(WORD SourceSegment) strcpy(DestBuffer, Ptr); /* Advance to the next string */ - Ptr += strlen(Ptr) + 1; DestBuffer += strlen(Ptr); + Ptr += strlen(Ptr) + 1; /* Put a zero after the string */ *(DestBuffer++) = 0; @@ -231,6 +231,8 @@ WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable) PDOS_MCB CurrentMcb, NextMcb; BOOLEAN SearchUmb = FALSE; + DPRINT("DosAllocateMemory: Size 0x%04X\n", Size); + if (DosUmbLinked && (DosAllocStrategy & (DOS_ALLOC_HIGH | DOS_ALLOC_HIGH_LOW))) { /* Search UMB first */ @@ -246,6 +248,7 @@ WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable) /* Make sure it's valid */ if (CurrentMcb->BlockType != 'M' && CurrentMcb->BlockType != 'Z') { + DPRINT("The DOS memory arena is corrupted!\n"); DosLastError = ERROR_ARENA_TRASHED; return 0; } @@ -1750,13 +1753,13 @@ BOOLEAN DosInitialize(VOID) /* Copy the string into DOS memory */ strcpy(DestPtr, AsciiString); - /* Free the memory */ - HeapFree(GetProcessHeap(), 0, AsciiString); - /* Move to the next string */ SourcePtr += wcslen(SourcePtr) + 1; DestPtr += strlen(AsciiString); *(DestPtr++) = 0; + + /* Free the memory */ + HeapFree(GetProcessHeap(), 0, AsciiString); } *DestPtr = 0; -- 2.17.1