diff options
author | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-25 15:58:59 +0000 |
---|---|---|
committer | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-25 15:58:59 +0000 |
commit | bf1c5ea44c8098917fda86c5ecd18befd9e40844 (patch) | |
tree | 21a8a7aa21eef9922d9af98d4ed499f7090bd790 /compiler/pmodules.pas | |
parent | ad68af41e644837d3e0bb7b1934f4eaa336d5af4 (diff) | |
download | fpc-bf1c5ea44c8098917fda86c5ecd18befd9e40844.tar.gz |
* prevention of dangling pointers and use after free after free_unregistered_localsymtable_elements
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49262 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/pmodules.pas')
-rw-r--r-- | compiler/pmodules.pas | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index d5037f7d60..9094500eb5 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -614,6 +614,7 @@ implementation i: longint; def: tdef; sym: tsym; + tmpidx: Integer; begin for i:=current_module.localsymtable.deflist.count-1 downto 0 do begin @@ -633,6 +634,10 @@ implementation tprocdef(def).procsym.is_registered then tprocsym(tprocdef(def).procsym).ProcdefList.Remove(def); current_module.localsymtable.deletedef(def); + { this prevents a dangling pointer and use after free } + tmpidx:=current_module.deflist.IndexOfItem(def,FromEnd); + if tmpidx<>-1 then + current_module.deflist[tmpidx]:=nil; end; end; { from high to low so we hopefully have moves of less data } |