Ver Fonte

Avoid infinite loops with RTE 204 if heap is corrupted

git-svn-id: trunk@23845 -
pierre há 12 anos atrás
pai
commit
503b8c73c2
2 ficheiros alterados com 9 adições e 2 exclusões
  1. 3 0
      rtl/inc/heap.inc
  2. 6 2
      rtl/inc/system.inc

+ 3 - 0
rtl/inc/heap.inc

@@ -1571,6 +1571,9 @@ var
   i : longint;
 {$endif}
 begin
+  { Do not try to do anything if the heap manager already reported an error }
+  if (errorcode=203) or (errorcode=204) then
+    exit;
   loc_freelists := @freelists;
 {$ifdef FPC_HAS_FEATURE_THREADING}
   if heap_lock_use > 0 then

+ 6 - 2
rtl/inc/system.inc

@@ -989,10 +989,14 @@ Begin
 {$endif}
 {$ifdef LINUX}
   {sysfreemem already checks for nil}
-  sysfreemem(calculated_cmdline);
+  { Do not try to do anything if the heap manager already reported an error }
+  if (errorcode<>203) and (errorcode<>204) then
+    sysfreemem(calculated_cmdline);
 {$endif}
 {$ifdef BSD}
-  sysfreemem(cmdline);
+  { Do not try to do anything if the heap manager already reported an error }
+  if (errorcode<>203) and (errorcode<>204) then
+    sysfreemem(cmdline);
 {$endif}
 
 {$ifdef FPC_HAS_FEATURE_HEAP}