Fix issue with malloc_extend_top
- when calculating a correction to align next brk to page boundary, ensure that the correction is less than a page size - if allocating the correction fails, ensure that the top size is set to brk + sbrk_size (minus any front alignment made) Signed-off-by: Jeff Johnston <jjohnstn@redhat.com>
This commit is contained in:
parent
fcfea0ae2d
commit
4a3d0a5a5d
|
@ -2198,13 +2198,18 @@ static void malloc_extend_top(RARG nb) RDECL INTERNAL_SIZE_T nb;
|
|||
/* Guarantee the next brk will be at a page boundary */
|
||||
correction += pagesz - ((POINTER_UINT)(brk + sbrk_size) & (pagesz - 1));
|
||||
|
||||
/* To guarantee page boundary, correction should be less than pagesz */
|
||||
correction &= (pagesz - 1);
|
||||
|
||||
/* Allocate correction */
|
||||
new_brk = (char*)(MORECORE (correction));
|
||||
if (new_brk == (char*)(MORECORE_FAILURE))
|
||||
{
|
||||
correction = 0;
|
||||
correction_failed = 1;
|
||||
new_brk = brk;
|
||||
new_brk = brk + sbrk_size;
|
||||
if (front_misalign > 0)
|
||||
new_brk -= (MALLOC_ALIGNMENT) - front_misalign;
|
||||
}
|
||||
|
||||
sbrked_mem += correction;
|
||||
|
|
Loading…
Reference in New Issue