summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2011-08-31 06:37:29 (GMT)
committerJason Evans <je@fb.com>2011-08-31 06:37:29 (GMT)
commit46405e670f9b4831da9c24c15f0f3a537ef2606b (patch)
treee5195a8ebbb1c84ad014399aede7778076d44041
parent749c2a0ab62089891d8e40840fbf384f12cb8401 (diff)
downloadjemalloc-46405e670f9b4831da9c24c15f0f3a537ef2606b.zip
jemalloc-46405e670f9b4831da9c24c15f0f3a537ef2606b.tar.gz
jemalloc-46405e670f9b4831da9c24c15f0f3a537ef2606b.tar.bz2
Fix a prof-related bug in realloc().
Fix realloc() such that it only records the object passed in as freed if no OOM error occurs.
-rw-r--r--src/jemalloc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c
index b13b1bf..fd8bf52 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -1299,6 +1299,7 @@ JEMALLOC_P(realloc)(void *ptr, size_t size)
old_ctx = prof_ctx_get(ptr);
PROF_ALLOC_PREP(1, usize, cnt);
if (cnt == NULL) {
+ old_ctx = NULL;
ret = NULL;
goto OOM;
}
@@ -1308,8 +1309,13 @@ JEMALLOC_P(realloc)(void *ptr, size_t size)
false, false);
if (ret != NULL)
arena_prof_promoted(ret, usize);
- } else
+ else
+ old_ctx = NULL;
+ } else {
ret = iralloc(ptr, size, 0, 0, false, false);
+ if (ret == NULL)
+ old_ctx = NULL;
+ }
} else
#endif
{
@@ -1666,7 +1672,6 @@ JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
bool no_move = flags & ALLOCM_NO_MOVE;
#ifdef JEMALLOC_PROF
prof_thr_cnt_t *cnt;
- prof_ctx_t *old_ctx;
#endif
assert(ptr != NULL);
@@ -1687,8 +1692,8 @@ JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
*/
size_t max_usize = (alignment == 0) ? s2u(size+extra) :
sa2u(size+extra, alignment, NULL);
+ prof_ctx_t *old_ctx = prof_ctx_get(p);
old_size = isalloc(p);
- old_ctx = prof_ctx_get(p);
PROF_ALLOC_PREP(1, max_usize, cnt);
if (cnt == NULL)
goto OOM;