Skip to content

Commit 0930683

Browse files
authored
Merge pull request #3489 from greed-island/mem
fix bug in rt_realloc of mem.c, which may cause memory leak
2 parents 7f6755c + b082876 commit 0930683

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/mem.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,12 @@ void *rt_realloc(void *rmem, rt_size_t newsize)
489489
{
490490
((struct heap_mem *)&heap_ptr[mem2->next])->prev = ptr2;
491491
}
492+
493+
if (mem2 < lfree)
494+
{
495+
/* the splited struct is now the lowest */
496+
lfree = mem2;
497+
}
492498

493499
plug_holes(mem2);
494500

0 commit comments

Comments
 (0)