소스 검색

Update mem.c

rt_realloc may cause <lfree> change, if we don't change <lfree> timely, it may cause memory leakage
greed-island 5 년 전
부모
커밋
b082876c9b
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      src/mem.c

+ 6 - 0
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);