summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2012-03-21 15:47:12 -0700
committerBen Cheng <bccheng@google.com>2012-03-21 15:47:12 -0700
commiteaae81082cb76efa43a2c3fb57997b28ca270634 (patch)
tree9681625e91934782d14cc848ea9acb06995a3a67
parent891966d0209b17d27d8d1f7a94bc6404be93f7bf (diff)
downloadbionic-eaae81082cb76efa43a2c3fb57997b28ca270634.zip
bionic-eaae81082cb76efa43a2c3fb57997b28ca270634.tar.gz
bionic-eaae81082cb76efa43a2c3fb57997b28ca270634.tar.bz2
Initialize mspace->least_addr properly in the mmap path.
BUG: 6206963 Change-Id: Id2ab580246de50a4511b56a734a7bece98fb945c
-rw-r--r--libc/bionic/dlmalloc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libc/bionic/dlmalloc.c b/libc/bionic/dlmalloc.c
index 496cd1c..98ea9e9 100644
--- a/libc/bionic/dlmalloc.c
+++ b/libc/bionic/dlmalloc.c
@@ -3332,7 +3332,7 @@ static void* mmap_alloc(mstate m, size_t nb) {
chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD;
chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0;
- if (mm < m->least_addr)
+ if (m->least_addr == 0 || mm < m->least_addr)
m->least_addr = mm;
if ((m->footprint += mmsize) > m->max_footprint)
m->max_footprint = m->footprint;
@@ -3678,7 +3678,9 @@ static void* sys_alloc(mstate m, size_t nb) {
m->max_footprint = m->footprint;
if (!is_initialized(m)) { /* first-time initialization */
- m->seg.base = m->least_addr = tbase;
+ if (m->least_addr == 0 || tbase < m->least_addr)
+ m->least_addr = tbase;
+ m->seg.base = tbase;
m->seg.size = tsize;
m->seg.sflags = mmap_flag;
m->magic = mparams.magic;