From 6f03b4a65f941bc091d4fd570b8e133ac4bca16d Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 24 Sep 2024 10:58:47 +0900 Subject: [PATCH] [console] Use aligned malloc for menu progs Fixes ubsan's (random!) complaints about memblock not being aligned. I should probably look into making the progs loader code ensure the memory is aligned itself. --- libs/console/menu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/console/menu.c b/libs/console/menu.c index 1cb89f15c..72f2382a8 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -530,13 +530,21 @@ quit_f (void) static void * menu_allocate_progs_mem (progs_t *pr, int size) { - return malloc (size); +#ifdef _WIN32 + return _aligned_malloc (size, 64); +#else + return aligned_alloc (64, size); +#endif } static void menu_free_progs_mem (progs_t *pr, void *mem) { +#ifdef _WIN32 + _aligned_free (mem); +#else free (mem); +#endif } static void *