From dd3feb948c49e14f779580c09171f10ea42c11ba Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Tue, 13 Aug 2019 13:43:20 +0100 Subject: [PATCH] Deal with wrap around in statistics. --- src/mem/allocstats.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mem/allocstats.h b/src/mem/allocstats.h index 5519985..7b68ae7 100644 --- a/src/mem/allocstats.h +++ b/src/mem/allocstats.h @@ -141,7 +141,9 @@ namespace snmalloc UNUSED(size); #ifdef USE_SNMALLOC_STATS - bucketed_requests[bits::to_exp_mant(size)]++; + auto index = (size == 0) ? 0 : bits::to_exp_mant(size); + assert(index < TOTAL_BUCKETS); + bucketed_requests[index]++; #endif }