فهرست منبع

* 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 -
svenbarth 6 سال پیش
والد
کامیت
b5e6c0b98d
3فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 1 0
      compiler/pdecl.pas
  2. 1 0
      compiler/pdecobj.pas
  3. 9 0
      compiler/symdef.pas

+ 1 - 0
compiler/pdecl.pas

@@ -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;
 

+ 1 - 0
compiler/pdecobj.pas

@@ -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;
 

+ 9 - 0
compiler/symdef.pas

@@ -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;