diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in index 5b809bfa..8ba4a19a 100644 --- a/include/jemalloc/internal/jemalloc_internal.h.in +++ b/include/jemalloc/internal/jemalloc_internal.h.in @@ -813,7 +813,7 @@ sa2u(size_t size, size_t alignment) * Calculate the multi-page mapping that large_palloc() would need in * order to guarantee the alignment. */ - if (usize + large_pad + PAGE_CEILING(alignment) < usize) { + if (usize + large_pad + PAGE_CEILING(alignment) - PAGE < usize) { /* size_t overflow. */ return (0); } diff --git a/src/extent_mmap.c b/src/extent_mmap.c index 0dd3247e..23dd4f88 100644 --- a/src/extent_mmap.c +++ b/src/extent_mmap.c @@ -9,7 +9,7 @@ extent_alloc_mmap_slow(size_t size, size_t alignment, bool *zero, bool *commit) void *ret; size_t alloc_size; - alloc_size = size + alignment; + alloc_size = size + alignment - PAGE; /* Beware size_t wrap-around. */ if (alloc_size < size) return (NULL);