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.
This commit is contained in:
CTCaer 2020-03-09 08:39:31 +02:00
parent e6c1d9bf66
commit 8d5c52f087

View file

@ -11,6 +11,8 @@
#include "lv_math.h" #include "lv_math.h"
#include <string.h> #include <string.h>
#include <assert.h>
#if LV_MEM_CUSTOM != 0 #if LV_MEM_CUSTOM != 0
#include LV_MEM_CUSTOM_INCLUDE #include LV_MEM_CUSTOM_INCLUDE
#endif #endif
@ -41,9 +43,11 @@ typedef union {
MEM_UNIT d_size: 31; //Size off the data (1 means 4 bytes) MEM_UNIT d_size: 31; //Size off the data (1 means 4 bytes)
}; };
MEM_UNIT header; //The header (used + d_size) 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; } lv_mem_header_t;
static_assert(sizeof(lv_mem_header_t) == 32, "Node header must be 32 bytes!");
typedef struct { typedef struct {
lv_mem_header_t header; lv_mem_header_t header;
uint8_t first_data; /*First data byte in the allocated data (Just for easily create a pointer)*/ uint8_t first_data; /*First data byte in the allocated data (Just for easily create a pointer)*/