From b082876c9b06d8a883726e6ddec50c2b49b6c4da Mon Sep 17 00:00:00 2001 From: greed-island <62747314+greed-island@users.noreply.github.com> Date: Fri, 27 Mar 2020 18:57:29 +0800 Subject: [PATCH] Update mem.c rt_realloc may cause change, if we don't change timely, it may cause memory leakage --- src/mem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mem.c b/src/mem.c index 8099b6bb7e..c03c8b3452 100644 --- a/src/mem.c +++ b/src/mem.c @@ -489,6 +489,12 @@ void *rt_realloc(void *rmem, rt_size_t newsize) { ((struct heap_mem *)&heap_ptr[mem2->next])->prev = ptr2; } + + if (mem2 < lfree) + { + /* the splited struct is now the lowest */ + lfree = mem2; + } plug_holes(mem2);