Repository navigation
fix double free error in p/d_realloc_malloc (fixes #6023) - #6024
Conversation
* handle size == 0 separately (For size == 0, ESP-IDF frees ptr and returns null) * only free original buffer if realloc has failed (successful realloc() frees the old ptr)
WalkthroughThe realloc helpers now free the supplied pointer and return ChangesAllocator Reallocation Handling
Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Possibly related issues
Suggested labels: Suggested reviewers: Merge Risk:
|
Solves a free-after-free error in our memory reallocation functions (see #6023 for details). If realloc() succeeds but validateFreeHeap() rejects due to low memory, the function called free(ptr) on an invalid pointer. This can lead to crashes or later heap corruption abort. * handles size == 0 separately (For size == 0, ESP-IDF frees ptr and returns null) * only frees original buffer if realloc has failed (successful realloc() frees the old ptr)
What it does
Solves a free-after-free error in our memory reallocation functions (see #6023 for details).
If realloc() succeeds but validateFreeHeap() rejects due to low memory, the function called free(ptr) on an invalid pointer. This can lead to crashes or later heap corruption abort.
AI assistance: no
Not while my own bio brains are still functioning ;-D
Checklist
Summary by CodeRabbit