Browse Source

* handle SysTinyFreeMem(nil) properly (i.e. succeed silently, without writing to
nil pointer memory)

git-svn-id: trunk@26890 -

nickysn 11 years ago
parent
commit
858efec84e
1 changed files with 5 additions and 0 deletions
  1. 5 0
      rtl/inc/tinyheap.inc

+ 5 - 0
rtl/inc/tinyheap.inc

@@ -180,6 +180,11 @@
 {$ifdef DEBUG_TINY_HEAP}
 {$ifdef DEBUG_TINY_HEAP}
         Writeln('SysTinyFreeMem(', ptruint(Addr), ')');
         Writeln('SysTinyFreeMem(', ptruint(Addr), ')');
 {$endif DEBUG_TINY_HEAP}
 {$endif DEBUG_TINY_HEAP}
+        if addr=nil then
+          begin
+            result:=0;
+            exit;
+          end;
         sz := Align(FindSize(addr)+SizeOf(ptruint), sizeof(pointer));
         sz := Align(FindSize(addr)+SizeOf(ptruint), sizeof(pointer));
 
 
         InternalTinyFreeMem(@pptruint(addr)[-1], sz);
         InternalTinyFreeMem(@pptruint(addr)[-1], sz);