Browse Source

+ 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 years ago
parent
commit
70850f0ce6
1 changed files with 3 additions and 0 deletions
  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);