diff --git a/CHANGELOG b/CHANGELOG index 03878d413..cff6b3095 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,11 @@ Next version + - INT 21h AH=4Ah resize memory: Fix bug where, if asked to resize a previously + freed memory block and the block is not the last block in the MCB chain, + and the next block in the MCB chain is also free, the MCB management code + would correctly compact free blocks but then allocate according to the + old size of the freed MCB block, causing truncation of the MCB chain. + Fix for MCB chain truncation caused by California Games II DOS memory + management when running in Tandy graphics mode. (joncampbell123). - Add dosbox.conf option, disabled by default, where if the MCB memory chain is corrupted anywhere past the running program's memory block, and it does anything to cause allocation, a new free memory block is diff --git a/src/dos/dos_memory.cpp b/src/dos/dos_memory.cpp index beaf3b8f8..103f15561 100644 --- a/src/dos/dos_memory.cpp +++ b/src/dos/dos_memory.cpp @@ -393,7 +393,11 @@ bool DOS_ResizeMemory(uint16_t segment,uint16_t * blocks) { else DOS_CompressMemory(); - total=mcb.GetSize(); /* DOS_CompressMemory() may change the MCB block size if this is a free block */ + /* DOS_CompressMemory() may change the MCB block size if this is a free block when it combines consecutive free blocks. + * If you don't think this could be a free block, understand that there are DOS applications and games out there + * that like to allocate memory by resizing a previously freed block. The Tandy version of California Games II + * does this, for example, as does (noted behlow) some Demoscene code. */ + total=mcb.GetSize(); DOS_MCB mcb_next(segment+total); if (*blocks<=total) {