From 243c587b7018ec55da6a885a7d0c66b3f7da772d Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Wed, 21 May 2025 18:43:25 +0700 Subject: [PATCH] fix(heap): avoid malloc calls optimization GCC defines that malloc(0) returns a non-null pointer (glibc behavior). This can break logic for some cases, because our implementation of malloc(0) returns null pointer. POSIX and the ISO C standard allow both behaviors. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13151b9001..1cd2e791ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,7 +170,7 @@ if(CONFIG_COMPILER_DUMP_RTL_FILES) endif() if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0) - list(APPEND c_compile_options "-fzero-init-padding-bits=all") + list(APPEND c_compile_options "-fzero-init-padding-bits=all" "-fno-malloc-dce") endif() __generate_prefix_map(prefix_map_compile_options)