浏览代码

Merge pull request #413 from grissiom/fix-memheap

memheap: check against over written in rt_memheap_free
Bernard Xiong 10 年之前
父节点
当前提交
2475568190
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      src/memheap.c

+ 2 - 0
src/memheap.c

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