diff options
author | jasone <jasone@FreeBSD.org> | 2008-06-10 15:46:18 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2008-06-10 15:46:18 +0000 |
commit | ab071c304d74d464b47feb83f1353d6dfe5e1b1f (patch) | |
tree | d366b03179198d622c72c11e5d224cdee0e6d44d /lib/libc/stdlib | |
parent | f0118f1998cf712a3bf3c0348f064299c5cbb80c (diff) | |
download | FreeBSD-src-ab071c304d74d464b47feb83f1353d6dfe5e1b1f.zip FreeBSD-src-ab071c304d74d464b47feb83f1353d6dfe5e1b1f.tar.gz |
In the error path through base_alloc(), release base_mtx [1].
Fix bit vector initialization for run headers.
Submitted by: [1] Mike Schuster <schuster@adobe.com>
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/malloc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 01160f4..629d343 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1296,8 +1296,10 @@ base_alloc(size_t size) malloc_mutex_lock(&base_mtx); /* Make sure there's enough space for the allocation. */ if ((uintptr_t)base_next_addr + csize > (uintptr_t)base_past_addr) { - if (base_pages_alloc(csize)) + if (base_pages_alloc(csize)) { + malloc_mutex_unlock(&base_mtx); return (NULL); + } } /* Allocate. */ ret = base_next_addr; @@ -2684,10 +2686,12 @@ arena_bin_nonfull_run_get(arena_t *arena, arena_bin_t *bin) /* Initialize run internals. */ run->bin = bin; - for (i = 0; i < bin->regs_mask_nelms; i++) + for (i = 0; i < bin->regs_mask_nelms - 1; i++) run->regs_mask[i] = UINT_MAX; remainder = bin->nregs & ((1U << (SIZEOF_INT_2POW + 3)) - 1); - if (remainder != 0) { + if (remainder == 0) + run->regs_mask[i] = UINT_MAX; + else { /* The last element has spare bits that need to be unset. */ run->regs_mask[i] = (UINT_MAX >> ((1U << (SIZEOF_INT_2POW + 3)) - remainder)); |