From 3fb50b0407ff7dfe14727995706e2b42836f0f7e Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Wed, 25 Apr 2012 13:13:44 -0700 Subject: Fix a PROF_ALLOC_PREP() error path. Fix a PROF_ALLOC_PREP() error path to initialize the return value to NULL. --- include/jemalloc/internal/prof.h | 4 +++- src/jemalloc.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/jemalloc/internal/prof.h b/include/jemalloc/internal/prof.h index 093ac93..4c39851 100644 --- a/include/jemalloc/internal/prof.h +++ b/include/jemalloc/internal/prof.h @@ -227,8 +227,10 @@ bool prof_boot2(void); assert(size == s2u(size)); \ \ prof_tdata = prof_tdata_get(); \ - if (prof_tdata == NULL) \ + if (prof_tdata == NULL) { \ + ret = NULL; \ break; \ + } \ \ if (opt_prof_active == false) { \ /* Sampling is currently inactive, so avoid sampling. */\ diff --git a/src/jemalloc.c b/src/jemalloc.c index d9fecef..52296e0 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1384,7 +1384,6 @@ je_allocm(void **ptr, size_t *rsize, size_t size, int flags) size_t alignment = (ZU(1) << (flags & ALLOCM_LG_ALIGN_MASK) & (SIZE_T_MAX-1)); bool zero = flags & ALLOCM_ZERO; - prof_thr_cnt_t *cnt; assert(ptr != NULL); assert(size != 0); @@ -1397,6 +1396,8 @@ je_allocm(void **ptr, size_t *rsize, size_t size, int flags) goto label_oom; if (config_prof && opt_prof) { + prof_thr_cnt_t *cnt; + PROF_ALLOC_PREP(1, usize, cnt); if (cnt == NULL) goto label_oom; @@ -1456,7 +1457,6 @@ je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, int flags) & (SIZE_T_MAX-1)); bool zero = flags & ALLOCM_ZERO; bool no_move = flags & ALLOCM_NO_MOVE; - prof_thr_cnt_t *cnt; assert(ptr != NULL); assert(*ptr != NULL); @@ -1466,6 +1466,8 @@ je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, int flags) p = *ptr; if (config_prof && opt_prof) { + prof_thr_cnt_t *cnt; + /* * usize isn't knowable before iralloc() returns when extra is * non-zero. Therefore, compute its maximum possible value and -- cgit v0.12