mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
heap_caps_calloc_base() calls heap_caps_malloc_base() from the same translation unit (heap_caps_base.c). GNU ld --wrap only redirects undefined references, so that intra-object call binds to the real heap_caps_malloc_base and never enters __wrap_heap_caps_malloc_base. As a result, allocations made through heap_caps_calloc() were never recorded by heap tracing, silently hiding potentially large INTERNAL leaks (e.g. mbedtls SSL buffers via MALLOC_CAP_INTERNAL). Add heap_caps_calloc_base to the --wrap list and implement __wrap_heap_caps_calloc_base, which records the allocation via a noinline trace_calloc helper (mirroring trace_malloc so the recorded call stack depth stays consistent) and calls __real_heap_caps_calloc_base. The inner malloc_base call remains same-TU and unwrapped, so each calloc produces exactly one trace record (no double counting).