--- pdksh-5.2.14/alloc.c.orig Mon Jul 2 01:57:07 2001 +++ pdksh-5.2.14/alloc.c Mon Jul 2 02:05:37 2001 @@ -293,7 +293,9 @@ * working (as it assumes size < ICELLS means it is not * a `large object'). */ - if (oldcells > ICELLS && cells > ICELLS) { + if (oldcells > ICELLS && cells > ICELLS + && ((dp-2)->block->last == dp+oldcells) && (((Cell*)((dp-2)->block+1))+NOBJECT_FIELDS == dp) /* don't destroy blocks which have grown! */ + ) { Block *bp = (dp-2)->block; Block *nbp; /* Saved in case realloc fails.. */ @@ -343,7 +345,7 @@ * (need to check that cells < ICELLS so we don't make an * object a `large' - that would mess everything up). */ - if (dp && cells > oldcells && cells <= ICELLS) { + if (dp && cells > oldcells) { Cell *fp, *fpp; Block *bp = (dp-2)->block; int need = cells - oldcells - NOBJECT_FIELDS; @@ -374,7 +376,7 @@ * it to malloc...) * Note: this also handles cells == oldcells (a no-op). */ - if (dp && cells <= oldcells && oldcells <= ICELLS) { + if (dp && cells <= oldcells) { int split; split = oldcells - cells; @@ -422,7 +424,9 @@ /* If this is a large object, just free it up... */ /* Release object... */ - if ((dp-1)->size > ICELLS) { + if ((dp-1)->size > ICELLS + && (bp->last == dp + (dp-1)->size) && (((Cell*)(bp+1))+NOBJECT_FIELDS == dp) /* don't free non-free blocks which have grown! */ + ) { ablockfree(bp, ap); ACHECK(ap); return;