summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWan-Teh Chang <wtc@google.com>2013-05-21 22:39:36 -0700
committerWan-Teh Chang <wtc@google.com>2013-05-21 22:39:36 -0700
commite8261d221bcb516351a709bc73f7e146f0642917 (patch)
tree8c15af1887126600e832aff2c7c7213df198c1d9
parent9881d3bbc071f7c79a5d06e77d6f4fb48e4d032e (diff)
downloadnspr-hg-e8261d221bcb516351a709bc73f7e146f0642917.tar.gz
Bug 844513: PL_ARENA_ALLOCATE should not let PL_ArenaAllocate unpoisonNSPR_4_10_BETA2
the alignment gap. Use an unsigned char* typecast for pointer arithmetic. r=matspal,choller.
-rw-r--r--lib/ds/plarena.c3
-rw-r--r--lib/ds/plarena.h4
-rw-r--r--lib/ds/plarenas.h3
3 files changed, 5 insertions, 5 deletions
diff --git a/lib/ds/plarena.c b/lib/ds/plarena.c
index 211dd671..23610ea8 100644
--- a/lib/ds/plarena.c
+++ b/lib/ds/plarena.c
@@ -157,7 +157,6 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
pool->current = a;
rp = (char *)a->avail;
a->avail += nb;
- PL_MAKE_MEM_UNDEFINED(rp, nb);
return rp;
}
} while( NULL != (a = a->next) );
@@ -188,7 +187,6 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
pool->current = a;
if ( NULL == pool->first.next )
pool->first.next = a;
- PL_MAKE_MEM_UNDEFINED(rp, nb);
return(rp);
}
}
@@ -215,7 +213,6 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
pool->first.next = a;
PL_COUNT_ARENA(pool,++);
COUNT(pool, nmallocs);
- PL_MAKE_MEM_UNDEFINED(rp, nb);
return(rp);
}
}
diff --git a/lib/ds/plarena.h b/lib/ds/plarena.h
index c4974304..8dcfb3e5 100644
--- a/lib/ds/plarena.h
+++ b/lib/ds/plarena.h
@@ -143,10 +143,10 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
if (_q > _a->limit) { \
_p = (PRUword)PL_ArenaAllocate(pool, _nb); \
} else { \
- PL_MAKE_MEM_UNDEFINED((void *)_p, nb); \
_a->avail = _q; \
} \
p = (void *)_p; \
+ PL_MAKE_MEM_UNDEFINED(p, nb); \
PL_ArenaCountAllocation(pool, nb); \
PR_END_MACRO
@@ -158,7 +158,7 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
PRUword _q = _p + _incr; \
if (_p == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
_q <= _a->limit) { \
- PL_MAKE_MEM_UNDEFINED((void *)((PRUword)(p) + size), incr); \
+ PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, incr); \
_a->avail = _q; \
PL_ArenaCountInplaceGrowth(pool, size, incr); \
} else { \
diff --git a/lib/ds/plarenas.h b/lib/ds/plarenas.h
index f4a00cd1..98bd7f87 100644
--- a/lib/ds/plarenas.h
+++ b/lib/ds/plarenas.h
@@ -47,6 +47,9 @@ PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
/*
** Friend functions used by the PL_ARENA_*() macros.
+**
+** WARNING: do not call these functions directly. Always use the
+** PL_ARENA_*() macros.
**/
PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);