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 years ago
parent
commit
d8f02107a1
1 changed files with 5 additions and 0 deletions
  1. 5 0
      compiler/pparautl.pas

+ 5 - 0
compiler/pparautl.pas

@@ -780,6 +780,7 @@ implementation
         forwardfound : boolean;
         forwardfound : boolean;
         symentry: TSymEntry;
         symentry: TSymEntry;
         item : tlinkedlistitem;
         item : tlinkedlistitem;
+        tmpidx: Integer;
       begin
       begin
         forwardfound:=false;
         forwardfound:=false;
 
 
@@ -1092,6 +1093,10 @@ implementation
 
 
                    { Release current procdef }
                    { Release current procdef }
                    currpd.owner.deletedef(currpd);
                    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;
                    currpd:=fwpd;
                  end
                  end
                else
                else