mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 11:09:42 +02:00
* prevention of dangling pointers and use after free after free_unregistered_localsymtable_elements
git-svn-id: trunk@49262 -
This commit is contained in:
parent
5557dbedf2
commit
1a71ca4106
@ -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 }
|
||||
|
Loading…
Reference in New Issue
Block a user