From: H. Peter Anvin Date: Wed, 27 Feb 2008 20:44:52 +0000 (-0800) Subject: realloc(): put an absolute upper limit on slack X-Git-Tag: syslinux-3.70-pre1~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd8d65961f2b6a45af1ceb7813b7012c0f6691b6;p=profile%2Fivi%2Fsyslinux.git realloc(): put an absolute upper limit on slack With loadfile() doing megabyte-sized trial-and-error allocations, we want to be able to do really set the size on the final allocation; thus constrain the amount of permitted slack to 4K max. --- diff --git a/com32/lib/realloc.c b/com32/lib/realloc.c index 89b63c8..2161a75 100644 --- a/com32/lib/realloc.c +++ b/com32/lib/realloc.c @@ -31,7 +31,8 @@ void *realloc(void *ptr, size_t size) /* Add the obligatory arena header, and round up */ newsize = (size+2*sizeof(struct arena_header)-1) & ARENA_SIZE_MASK; - if ( oldsize >= newsize && newsize >= (oldsize >> 2) ) { + if ( oldsize >= newsize && newsize >= (oldsize >> 2) && + oldsize-newsize < 4096 ) { /* This allocation is close enough already. */ return ptr; } else {