diff --git a/newlib/libc/stdlib/nano-mallocr.c b/newlib/libc/stdlib/nano-mallocr.c index 99ad60dd0..43eb20e07 100644 --- a/newlib/libc/stdlib/nano-mallocr.c +++ b/newlib/libc/stdlib/nano-mallocr.c @@ -336,6 +336,15 @@ void * nano_malloc(RARG malloc_size_t s) if (sbrk_aligned(RCALL alloc_size) != (void *)-1) { p->size += alloc_size; + + /* Remove chunk from free_list */ + r = free_list; + while (r && p != r->next) + { + r = r->next; + } + r->next = NULL; + r = p; } else