浏览代码

+ tinyheap: check and generate runtime error 204 if an attempt is made to free a
memory block that is outside the heap

git-svn-id: trunk@28446 -

nickysn 11 年之前
父节点
当前提交
70850f0ce6
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      rtl/inc/tinyheap.inc

+ 3 - 0
rtl/inc/tinyheap.inc

@@ -208,6 +208,9 @@
             result:=0;
             exit;
           end;
+        if (TTinyHeapPointerArithmeticType(addr) < TTinyHeapPointerArithmeticType(HeapOrg)) or
+           (TTinyHeapPointerArithmeticType(addr) >= TTinyHeapPointerArithmeticType(HeapEnd)) then
+          HandleError(204);
         sz := Align(FindSize(addr)+SizeOf(TTinyHeapMemBlockSize), TinyHeapAllocGranularity);
 
         InternalTinyFreeMem(@PTinyHeapMemBlockSize(addr)[-1], sz);