From f36890102fbbda2d1edddd9006c08d787f0acca8 Mon Sep 17 00:00:00 2001 From: Neo Xu Date: Sun, 21 Jul 2024 16:34:36 +0800 Subject: [PATCH] fix(sdl): make sure minimal alignment is sizeof(void*) for aligned alloc (#6526) --- src/drivers/sdl/lv_sdl_window.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/drivers/sdl/lv_sdl_window.c b/src/drivers/sdl/lv_sdl_window.c index 35e834f072..2844112679 100644 --- a/src/drivers/sdl/lv_sdl_window.c +++ b/src/drivers/sdl/lv_sdl_window.c @@ -442,7 +442,9 @@ static void * sdl_draw_buf_realloc_aligned(void * ptr, size_t new_size) #ifndef _WIN32 /* Size must be multiple of align, See: https://en.cppreference.com/w/c/memory/aligned_alloc */ - return aligned_alloc(LV_DRAW_BUF_ALIGN, LV_ALIGN_UP(new_size, LV_DRAW_BUF_ALIGN)); + +#define BUF_ALIGN (LV_DRAW_BUF_ALIGN < sizeof(void *) ? sizeof(void *) : LV_DRAW_BUF_ALIGN) + return aligned_alloc(BUF_ALIGN, LV_ALIGN_UP(new_size, BUF_ALIGN)); #else return _aligned_malloc(LV_ALIGN_UP(new_size, LV_DRAW_BUF_ALIGN), LV_DRAW_BUF_ALIGN); #endif /* _WIN32 */