aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-02-27 12:44:52 -0800
committerH. Peter Anvin <hpa@zytor.com>2008-02-27 12:44:52 -0800
commitdd8d65961f2b6a45af1ceb7813b7012c0f6691b6 (patch)
treee0f15f942e58352ba8112db28ba52dff8473e088 /com32/lib
parent48722c47bbdcfe51e905e87ec0d34415506393c5 (diff)
downloadsyslinux-elf-dd8d65961f2b6a45af1ceb7813b7012c0f6691b6.tar.gz
syslinux-elf-dd8d65961f2b6a45af1ceb7813b7012c0f6691b6.tar.xz
syslinux-elf-dd8d65961f2b6a45af1ceb7813b7012c0f6691b6.zip
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.
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/realloc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/com32/lib/realloc.c b/com32/lib/realloc.c
index 89b63c8e..2161a758 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 {