diff options
author | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-27 23:11:09 +0000 |
---|---|---|
committer | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-27 23:11:09 +0000 |
commit | a491c935588745154b576226b73833bac78fcb6e (patch) | |
tree | 973289073fb5d21573a6be2b5cfeba9abd2a9472 /compiler/pmodules.pas | |
parent | 38b5e0606069cc5985e995e1da5b6855db67f507 (diff) | |
parent | ae5b0de491a91321675f73eae5db628d068f4e05 (diff) | |
download | fpc-unicodekvm.tar.gz |
* synchronized with trunkunicodekvm
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/unicodekvm@49282 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/pmodules.pas')
-rw-r--r-- | compiler/pmodules.pas | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index 60f93e6ae4..9094500eb5 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -614,10 +614,14 @@ implementation i: longint; def: tdef; sym: tsym; + tmpidx: Integer; begin for i:=current_module.localsymtable.deflist.count-1 downto 0 do begin def:=tdef(current_module.localsymtable.deflist[i]); + { since commit 48986 deflist might have NIL entries } + if not assigned(def) then + continue; { this also frees def, as the defs are owned by the symtable } if not def.is_registered and not(df_not_registered_no_free in def.defoptions) then @@ -630,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 } |