浏览代码

Avoid infinite loops with RTE 204 if heap is corrupted

git-svn-id: trunk@23845 -
pierre 12 年之前
父节点
当前提交
503b8c73c2
共有 2 个文件被更改,包括 9 次插入2 次删除
  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;
   i : longint;
 {$endif}
 {$endif}
 begin
 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;
   loc_freelists := @freelists;
 {$ifdef FPC_HAS_FEATURE_THREADING}
 {$ifdef FPC_HAS_FEATURE_THREADING}
   if heap_lock_use > 0 then
   if heap_lock_use > 0 then

+ 6 - 2
rtl/inc/system.inc

@@ -989,10 +989,14 @@ Begin
 {$endif}
 {$endif}
 {$ifdef LINUX}
 {$ifdef LINUX}
   {sysfreemem already checks for nil}
   {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}
 {$endif}
 {$ifdef BSD}
 {$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}
 {$endif}
 
 
 {$ifdef FPC_HAS_FEATURE_HEAP}
 {$ifdef FPC_HAS_FEATURE_HEAP}