Update mem.c

rt_realloc may cause <lfree> change, if we don't change <lfree> timely, it may cause memory leakage
This commit is contained in:
greed-island 2020-03-27 18:57:29 +08:00 committed by GitHub
parent 7f6755c622
commit b082876c9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -490,6 +490,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);
rt_sem_release(&heap_sem);