Skip to content

Commit fe16cfc

Browse files
ecm-pushbxPerditionC
authored andcommitted
loadhigh_prepare: on MCB allocation error do not leak memory
1 parent 20e61b5 commit fe16cfc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

shell/loadhigh.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,13 @@ static int loadhigh_prepare(void)
462462
/* Found a free memory block: allocate it */
463463
word bl = DosAlloc(mcb->mcb_size);
464464

465-
if (bl != FP_SEG(mcb) + 1) /* Did we get the block we wanted? */
465+
if (bl != FP_SEG(mcb) + 1) { /* Did we get the block we wanted? */
466+
DOSfree(bl);
467+
for (i = 0; i < availBlocks; i++)
468+
DOSfree(availBlock[i]);
469+
free(availBlock);
466470
return err_mcb_chain;
471+
}
467472

468473
if (region->access) /* /L option allows access to this region */
469474
{

0 commit comments

Comments
 (0)