From a52ef8e41670776f6d3e0acc264a37a366696741 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 15 Nov 2004 09:49:06 +0000 Subject: * malloc/malloc.c (_int_free): Further free () protection checks. --- malloc/malloc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'malloc') diff --git a/malloc/malloc.c b/malloc/malloc.c index 57074108f1..f4612046cd 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -4233,6 +4233,14 @@ _int_free(mstate av, Void_t* mem) #endif ) { + if (__builtin_expect (chunksize (chunk_at_offset (p, size)) < MINSIZE, 0) + || __builtin_expect (chunksize (chunk_at_offset (p, size)) + >= av->system_mem, 0)) + { + errstr = "invalid next size (fast)"; + goto errout; + } + set_fastchunks(av); fb = &(av->fastbins[fastbin_index(size)]); /* Another simple check: make sure the top of the bin is not the -- cgit v1.2.3