* ensure that any potentially created constructor call is freed if the attribute is not bound to a def or sym

git-svn-id: trunk@42383 -
This commit is contained in:
svenbarth 2019-07-12 22:06:38 +00:00
parent 0e04d9b4de
commit b5e6c0b98d
3 changed files with 11 additions and 0 deletions

View File

@ -1040,6 +1040,7 @@ implementation
begin
add_synthetic_rtti_function_declarations(rtti_attrs_def,hdef.typesym.Name);
tobjectdef(hdef).rtti_attribute_list:=rtti_attrs_def;
rtti_attrs_def.is_bound:=true;
rtti_attrs_def := nil;
end;

View File

@ -218,6 +218,7 @@ implementation
begin
add_synthetic_rtti_function_declarations(rtti_attrs_def,current_structdef.RttiName+'_'+p.RealName);
p.rtti_attribute_list := rtti_attrs_def;
p.rtti_attribute_list.is_bound:=true;
rtti_attrs_def:=nil;
end;

View File

@ -70,6 +70,8 @@ interface
trtti_attribute_list = class
rtti_attributes : TFPObjectList;
{ if the attribute list is bound to a def or symbol }
is_bound : Boolean;
procedure addattribute(atypesym:tsym;constructorcall:tnode;constref paras:array of tnode);
destructor destroy; override;
function get_attribute_count:longint;
@ -2919,7 +2921,14 @@ implementation
end;
destructor trtti_attribute_list.destroy;
var
i : longint;
begin
{ if the attributes are not bound we need to free their generated
constructor functions as well }
if not is_bound and assigned(rtti_attributes) then
for i:=0 to rtti_attributes.count-1 do
trtti_attribute(rtti_attributes[i]).constructorcall.free;
rtti_attributes.Free;
inherited destroy;
end;