diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-05-11 20:48:50 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-05-11 20:48:50 +0000 |
commit | 8788ce3787ac33ece2f77ee530b7858b2bc202f3 (patch) | |
tree | 3a0c8d1e9cf225512c85c6366d2a78fff715d229 /libc/malloc/malloc.c | |
parent | 7900271c9a94743597a2d3e63c372a8e26fd02e0 (diff) |
Merge changes between r10371 and r10438 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@10439 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/malloc/malloc.c')
-rw-r--r-- | libc/malloc/malloc.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libc/malloc/malloc.c b/libc/malloc/malloc.c index 722b1d496..9594be4cb 100644 --- a/libc/malloc/malloc.c +++ b/libc/malloc/malloc.c @@ -4859,6 +4859,7 @@ _int_free(mstate av, mchunkptr p) #ifdef ATOMIC_FASTBINS mchunkptr fd; mchunkptr old = *fb; + unsigned int old_idx = ~0u; do { /* Another simple check: make sure the top of the bin is not the @@ -4868,15 +4869,17 @@ _int_free(mstate av, mchunkptr p) errstr = "double free or corruption (fasttop)"; goto errout; } - if (old != NULL - && __builtin_expect (fastbin_index(chunksize(old)) != idx, 0)) - { - errstr = "invalid fastbin entry (free)"; - goto errout; - } + if (old != NULL) + old_idx = fastbin_index(chunksize(old)); p->fd = fd = old; } while ((old = catomic_compare_and_exchange_val_rel (fb, p, fd)) != fd); + + if (fd != NULL && __builtin_expect (old_idx != idx, 0)) + { + errstr = "invalid fastbin entry (free)"; + goto errout; + } #else /* Another simple check: make sure the top of the bin is not the record we are going to add (i.e., double free). */ |