diff options
author | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-17 19:42:49 +0000 |
---|---|---|
committer | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-17 19:42:49 +0000 |
commit | 95f10f174917c96077a4b8a8da0d69d6fc775349 (patch) | |
tree | 822b5710c7df21b9246139d973e5e4c33ce65a6b | |
parent | f7341c9b55237fac0e32f5cdab8b46c6b4f8e3f3 (diff) | |
download | fpc-95f10f174917c96077a4b8a8da0d69d6fc775349.tar.gz |
* avoid leaving a dangling pointer in pparautl.proc_add_definition to prevent
use after free in different parts of the compiler
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49222 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | compiler/pparautl.pas | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/pparautl.pas b/compiler/pparautl.pas index 4608decce3..b139cd785d 100644 --- a/compiler/pparautl.pas +++ b/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 |