summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgreed-island <[email protected]>2020-03-27 18:57:29 +0800
committerGitHub <[email protected]>2020-03-27 18:57:29 +0800
commitb082876c9b06d8a883726e6ddec50c2b49b6c4da (patch)
tree4d1cb3e7edd84560324ffce7c0cdae09cda4076f
parent7f6755c622fd76394f0496752d7b33846f19ebe8 (diff)
Update mem.c
rt_realloc may cause <lfree> change, if we don't change <lfree> timely, it may cause memory leakage
-rw-r--r--src/mem.c6
1 files changed, 6 insertions, 0 deletions
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);