[PATCH 3/3] Don't use sizeof() on a VARIABLE_ARRAY

Mike Hommey mh+jemalloc at glandium.org
Wed May 2 12:30:53 PDT 2012


From: Mike Hommey <mh at glandium.org>

In the alloca() case, this fails to be the right size.
---
 src/stats.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/stats.c b/src/stats.c
index 1234e56..433b80d 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -494,7 +494,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
 				size_t isz;
 				unsigned i, ninitialized;
 
-				isz = sizeof(initialized);
+				isz = sizeof(bool) * narenas;
 				xmallctl("arenas.initialized", initialized,
 				    &isz, NULL, 0);
 				for (i = ninitialized = 0; i < narenas; i++) {
@@ -523,7 +523,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
 				size_t isz;
 				unsigned i;
 
-				isz = sizeof(initialized);
+				isz = sizeof(bool) * narenas;
 				xmallctl("arenas.initialized", initialized,
 				    &isz, NULL, 0);
 
-- 
1.7.10




More information about the jemalloc-discuss mailing list