From e4107040e9c6875153858ead386e3184a15c26b0 Mon Sep 17 00:00:00 2001 From: SG Date: Wed, 10 Apr 2024 21:08:19 +0300 Subject: [PATCH] aligned_alloc: check that alignment is correct --- furi/core/memmgr_heap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/furi/core/memmgr_heap.c b/furi/core/memmgr_heap.c index 5afeb8f67..4edb9c5bd 100644 --- a/furi/core/memmgr_heap.c +++ b/furi/core/memmgr_heap.c @@ -246,6 +246,11 @@ extern void* pvPortAllocAligned(size_t xSize, size_t xAlignment) { furi_crash("memmgt in ISR"); } + // alignment must be power of 2 + if((xAlignment & (xAlignment - 1)) != 0) { + furi_crash("invalid alignment"); + } + memmgr_lock(); // allocate block