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