From ec2a8f387b611a0e18fcbf6a2ec7472d6aa074cd Mon Sep 17 00:00:00 2001 From: daan Date: Thu, 27 Jun 2019 13:27:53 -0700 Subject: [PATCH] strengthen alignment check to be void* aligned --- src/alloc-aligned.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/alloc-aligned.c b/src/alloc-aligned.c index 34f129da..73769812 100644 --- a/src/alloc-aligned.c +++ b/src/alloc-aligned.c @@ -17,7 +17,7 @@ terms of the MIT license. A copy of the license can be found in the file static void* mi_heap_malloc_zero_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset, bool zero) mi_attr_noexcept { // note: we don't require `size > offset`, we just guarantee that // the address at offset is aligned regardless of the allocated size. - mi_assert(alignment > 0); + mi_assert(alignment > 0 && alignment % sizeof(uintptr_t) == 0); if (alignment <= sizeof(uintptr_t)) return _mi_heap_malloc_zero(heap,size,zero); if (size >= (SIZE_MAX - alignment)) return NULL; // overflow @@ -143,4 +143,3 @@ void* mi_recalloc_aligned(void* p, size_t count, size_t size, size_t alignment) if (mi_mul_overflow(count,size,&total)) return NULL; return mi_rezalloc_aligned(p,total,alignment); } -