From 6c2e0b73334a7405108424a2c4e71d0c07c447b3 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Thu, 19 Jan 2023 08:32:56 +0200 Subject: [PATCH] mm/mm_extend: Increase total heap size accordingly When adding more heap memory, the total heap size was not updated. This results in a crash in mm_mallinfo: DEBUGASSERT((size_t)info->uordblks + info->fordblks == heap->mm_heapsize); This commit fixes this issue --- mm/mm_heap/mm_extend.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/mm_heap/mm_extend.c b/mm/mm_heap/mm_extend.c index 9ffc7e74cbb..8ff2ddec0b7 100644 --- a/mm/mm_heap/mm_extend.c +++ b/mm/mm_heap/mm_extend.c @@ -106,6 +106,10 @@ void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size, newnode->preceding = oldnode->size | MM_ALLOC_BIT; heap->mm_heapend[region] = newnode; + + /* Finally, increase the total heap size accordingly */ + + heap->mm_heapsize += size; mm_unlock(heap); /* Finally "free" the new block of memory where the old terminal node was