From 8d5c52f087584d8f0c43fca2375abc49ed2da420 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Mon, 9 Mar 2020 08:39:31 +0200 Subject: [PATCH] lvgl heap: Fix critical issue with node header size This fixes a critical issue where the node header was 28 bytes instead of 32, causing misalignment and heap corruption. --- nyx/nyx_gui/libs/lvgl/lv_misc/lv_mem.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nyx/nyx_gui/libs/lvgl/lv_misc/lv_mem.c b/nyx/nyx_gui/libs/lvgl/lv_misc/lv_mem.c index 9156e86..e100d26 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_misc/lv_mem.c +++ b/nyx/nyx_gui/libs/lvgl/lv_misc/lv_mem.c @@ -11,6 +11,8 @@ #include "lv_math.h" #include +#include + #if LV_MEM_CUSTOM != 0 #include LV_MEM_CUSTOM_INCLUDE #endif @@ -41,9 +43,11 @@ typedef union { MEM_UNIT d_size: 31; //Size off the data (1 means 4 bytes) }; MEM_UNIT header; //The header (used + d_size) - uint32_t align[7]; //Align header size to 32 bytes + uint32_t align[8]; //Align header size to 32 bytes } lv_mem_header_t; +static_assert(sizeof(lv_mem_header_t) == 32, "Node header must be 32 bytes!"); + typedef struct { lv_mem_header_t header; uint8_t first_data; /*First data byte in the allocated data (Just for easily create a pointer)*/