Browse Source

* avoid leaving a dangling pointer in pparautl.proc_add_definition to prevent
use after free in different parts of the compiler

git-svn-id: trunk@49222 -

nickysn 4 năm trước cách đây
mục cha
commit
d8f02107a1
1 tập tin đã thay đổi với 5 bổ sung0 xóa
  1. 5 0
      compiler/pparautl.pas

+ 5 - 0
compiler/pparautl.pas

@@ -780,6 +780,7 @@ implementation
         forwardfound : boolean;
         symentry: TSymEntry;
         item : tlinkedlistitem;
+        tmpidx: Integer;
       begin
         forwardfound:=false;
 
@@ -1092,6 +1093,10 @@ implementation
 
                    { Release current procdef }
                    currpd.owner.deletedef(currpd);
+                   { this prevents a dangling pointer and use after free }
+                   tmpidx:=current_module.deflist.IndexOfItem(currpd,FromEnd);
+                   if tmpidx<>-1 then
+                     current_module.deflist[tmpidx]:=nil;
                    currpd:=fwpd;
                  end
                else