소스 검색

memheap: check the USED bit in rt_memheap_free

This will ease the debugging of double-free bug.
Grissiom 10 년 전
부모
커밋
2d3b2f1e94
1개의 변경된 파일1개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      src/memheap.c

+ 1 - 0
src/memheap.c

@@ -517,6 +517,7 @@ void rt_memheap_free(void *ptr)
 
     /* check magic */
     RT_ASSERT((header_ptr->magic & RT_MEMHEAP_MASK) == RT_MEMHEAP_MAGIC);
+    RT_ASSERT(header_ptr->magic & RT_MEMHEAP_USED);
     /* check whether this block of memory has been over-written. */
     RT_ASSERT((header_ptr->next->magic & RT_MEMHEAP_MASK) == RT_MEMHEAP_MAGIC);