Преглед изворни кода

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