Skip to content

Commit 5d83f21

Browse files
committed
some more bugfixes cherry picked from FDPP
1 parent 30808f9 commit 5d83f21

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

kernel/memmgr.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ COUNT DosMemFree(UWORD para)
298298
if (!mcbFreeable(p)) /* does not have to be valid, freeable is enough */
299299
return DE_INVLDMCB;
300300

301+
/* ignore double free */
302+
if (mcbFree(p))
303+
return SUCCESS;
304+
301305
/* Mark the mcb as free so that we can later */
302306
/* merge with other surrounding free MCBs */
303307
p->m_psp = FREE_PSP;
@@ -311,6 +315,8 @@ COUNT DosMemFree(UWORD para)
311315
* para is the segment of the data portion of the block rather than
312316
* the segment of the MCB itself.
313317
*
318+
* Resize on an unallocated block is allowed and makes it allocated.
319+
*
314320
* If the block shall grow, it is resized to the maximal size less than
315321
* or equal to size. This is the way MS DOS is reported to work.
316322
*/
@@ -358,7 +364,12 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize)
358364
/* Mark the mcb as free so that we can later */
359365
/* merge with other surrounding free MCBs */
360366
q->m_psp = FREE_PSP;
367+
368+
/* Alone in the Dark game accesses the free area after realloc.
369+
* It will crash with the below memset() - disable to match MS-DOS. */
370+
#if 0
361371
fmemset(q->m_name, '\0', 8);
372+
#endif
362373

363374
/* try to join q with the free MCBs following it if possible */
364375
if (joinMCBs(FP_SEG(q)) != SUCCESS)

0 commit comments

Comments
 (0)