Fix more pointer arithmetic undefined behavior.

Reported by Guilherme Gonçalves.

This resolves #166.
This commit is contained in:
Jason Evans 2014-11-17 10:31:59 -08:00
parent 2012d5a560
commit d49cb68b9e

View File

@ -2341,12 +2341,12 @@ arena_new(unsigned ind)
if (config_stats) {
memset(&arena->stats, 0, sizeof(arena_stats_t));
arena->stats.lstats = (malloc_large_stats_t *)(((void *)arena) +
CACHELINE_CEILING(sizeof(arena_t)));
arena->stats.lstats = (malloc_large_stats_t *)((uintptr_t)arena
+ CACHELINE_CEILING(sizeof(arena_t)));
memset(arena->stats.lstats, 0, nlclasses *
sizeof(malloc_large_stats_t));
arena->stats.hstats = (malloc_huge_stats_t *)(((void *)arena) +
CACHELINE_CEILING(sizeof(arena_t)) +
arena->stats.hstats = (malloc_huge_stats_t *)((uintptr_t)arena
+ CACHELINE_CEILING(sizeof(arena_t)) +
QUANTUM_CEILING(nlclasses * sizeof(malloc_large_stats_t)));
memset(arena->stats.hstats, 0, nhclasses *
sizeof(malloc_huge_stats_t));