From 38127291670af8d12a21eb78ba49201f3a5af7d1 Mon Sep 17 00:00:00 2001 From: Dave Watson Date: Wed, 24 Feb 2016 20:10:02 -0800 Subject: [PATCH] Fix arena_size computation. Fix arena_size arena_new() computation to incorporate runs_avail_nclasses elements for runs_avail, rather than (runs_avail_nclasses - 1) elements. Since offsetof(arena_t, runs_avail) is used rather than sizeof(arena_t) for the first term of the computation, all of the runs_avail elements must be added into the second term. This bug was introduced (by Jason Evans) while merging pull request #330 as 3417a304ccde61ac1f68b436ec22c03f1d6824ec (Separate arena_avail trees). --- src/arena.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arena.c b/src/arena.c index 3b125b05..ad675d13 100644 --- a/src/arena.c +++ b/src/arena.c @@ -3271,7 +3271,7 @@ arena_new(unsigned ind) /* Compute arena size to incorporate sufficient runs_avail elements. */ arena_size = offsetof(arena_t, runs_avail) + (sizeof(arena_run_tree_t) * - (runs_avail_nclasses - 1)); + runs_avail_nclasses); /* * Allocate arena, arena->lstats, and arena->hstats contiguously, mainly * because there is no way to clean up if base_alloc() OOMs.