From cf53b1138768a9b28ea0f07a2c8d0581767ede4f Mon Sep 17 00:00:00 2001 From: jatin Date: Sun, 21 Apr 2024 00:04:22 -0700 Subject: [PATCH] Aligned Alloc fix --- modules/common/chowdsp_core/Memory/chowdsp_AlignedAlloc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/common/chowdsp_core/Memory/chowdsp_AlignedAlloc.h b/modules/common/chowdsp_core/Memory/chowdsp_AlignedAlloc.h index 2bb9825b4..dbc8bb87a 100644 --- a/modules/common/chowdsp_core/Memory/chowdsp_AlignedAlloc.h +++ b/modules/common/chowdsp_core/Memory/chowdsp_AlignedAlloc.h @@ -43,7 +43,9 @@ inline void aligned_free (void* data) #pragma clang diagnostic ignored "-Wunguarded-availability-new" #endif - return std::aligned_alloc (alignment, size); + // size is required to be a multiple of alignment! + const auto size_padded = ((size + alignment - 1) / alignment) * alignment; + return std::aligned_alloc (alignment, size_padded); #ifdef __clang__ #pragma clang diagnostic pop