mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-11 00:49:29 +02:00
* set self to nil in current_module.deflist for registered defs in the
tstoreddef.destroy destructor, instead of doing it after each call to x.owner.deletedef(x) git-svn-id: trunk@49417 -
This commit is contained in:
parent
93fea6de3a
commit
ea5ffd597f
@ -1651,7 +1651,6 @@ implementation
|
||||
is_first_type: boolean;
|
||||
{$endif powerpc or powerpc64}
|
||||
old_block_type: tblock_type;
|
||||
tmpidx: Integer;
|
||||
begin
|
||||
old_block_type:=block_type;
|
||||
block_type:=bt_var;
|
||||
@ -2022,10 +2021,6 @@ implementation
|
||||
|
||||
trecordsymtable(recst).insertunionst(Unionsymtable,offset);
|
||||
uniondef.owner.deletedef(uniondef);
|
||||
{ this prevents a dangling pointer and use after free }
|
||||
tmpidx:=current_module.deflist.IndexOfItem(uniondef,FromEnd);
|
||||
if tmpidx<>-1 then
|
||||
current_module.deflist[tmpidx]:=nil;
|
||||
end;
|
||||
{ free the list }
|
||||
sc.free;
|
||||
|
@ -614,7 +614,6 @@ implementation
|
||||
i: longint;
|
||||
def: tdef;
|
||||
sym: tsym;
|
||||
tmpidx: Integer;
|
||||
begin
|
||||
for i:=current_module.localsymtable.deflist.count-1 downto 0 do
|
||||
begin
|
||||
@ -634,10 +633,6 @@ 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 }
|
||||
|
@ -780,7 +780,6 @@ implementation
|
||||
forwardfound : boolean;
|
||||
symentry: TSymEntry;
|
||||
item : tlinkedlistitem;
|
||||
tmpidx: Integer;
|
||||
begin
|
||||
forwardfound:=false;
|
||||
|
||||
@ -1093,10 +1092,6 @@ 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
|
||||
|
@ -1987,6 +1987,12 @@ implementation
|
||||
{$ifndef symansistr}
|
||||
stringdispose(_fullownerhierarchyname);
|
||||
{$endif not symansistr}
|
||||
{ set self to nil in current_module's deflist, if the def has been
|
||||
registered, in order to avoid dangling pointers in current_module.deflist }
|
||||
if registered and assigned(current_module) and
|
||||
(defid>=0) and (defid<current_module.deflist.Count) and
|
||||
(current_module.deflist[defid]=self) then
|
||||
current_module.deflist[defid]:=nil;
|
||||
inherited destroy;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user