From 0d1addf0d41e89d9f30ee70772df0938c7880a71 Mon Sep 17 00:00:00 2001 From: Nakst Date: Sun, 14 Mar 2021 20:36:35 +0000 Subject: [PATCH] Make size of allocation multiple of the alignment To silence an error from GCC's address sanitizer. --- src/gb/gb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gb/gb.h b/src/gb/gb.h index 687227dd3..b56c20f1e 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -5026,7 +5026,7 @@ GB_ALLOCATOR_PROC(gb_heap_allocator_proc) { #elif defined(GB_SYSTEM_LINUX) // TODO(bill): *nix version that's decent case gbAllocation_Alloc: { - ptr = aligned_alloc(alignment, size); + ptr = aligned_alloc(alignment, (size + alignment - 1) & ~(alignment - 1)); // ptr = malloc(size+alignment); if (flags & gbAllocatorFlag_ClearToZero) {