mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-07 17:08:49 +00:00
heap: Fix erroneous value returned by heap_caps_get_allocated_size() when poisoning is enabled
When light (or comprehensive) poisoning is enabled, the size requested by the user for allocation is extended by a few bytes to store the canary header and footer. heap_caps_get_allocated_size() should return the original size asked by the user (without the additional canary bytes). test_malloc.c extended with a new test assuring that heap_caps_get_allocated_size() returns the proper size regardless of the degree of poisoning.
This commit is contained in:
@@ -383,6 +383,7 @@ size_t multi_heap_get_allocated_size(multi_heap_handle_t heap, void *p)
|
||||
poison_head_t *head = verify_allocated_region(p, true);
|
||||
assert(head != NULL);
|
||||
size_t result = multi_heap_get_allocated_size_impl(heap, head);
|
||||
subtract_poison_overhead(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user