Parcourir la source

* fixed double free in LLVM code generator after r41963

git-svn-id: trunk@41976 -
Jonas Maebe il y a 6 ans
Parent
commit
079d616978
2 fichiers modifiés avec 4 ajouts et 7 suppressions
  1. 3 3
      compiler/aasmcnst.pas
  2. 1 4
      compiler/llvm/nllvmtcon.pas

+ 3 - 3
compiler/aasmcnst.pas

@@ -93,7 +93,7 @@ type
      procedure addvalue(val: tai_abstracttypedconst);
      function valuecount: longint;
      procedure insertvaluebeforepos(val: tai_abstracttypedconst; pos: longint);
-     function replacevalueatpos(val: tai_abstracttypedconst; pos: longint): tai_abstracttypedconst;
+     procedure replacevalueatpos(val: tai_abstracttypedconst; pos: longint);
      { change the type to a record, regardless of how the aggregate was created;
        the size of the original type and the record must match }
      procedure changetorecord(_def: trecorddef);
@@ -794,9 +794,9 @@ implementation
      end;
 
 
-   function tai_aggregatetypedconst.replacevalueatpos(val: tai_abstracttypedconst; pos: longint): tai_abstracttypedconst;
+   procedure tai_aggregatetypedconst.replacevalueatpos(val: tai_abstracttypedconst; pos: longint);
      begin
-       result:=tai_abstracttypedconst(fvalues[pos]);
+       { since fvalues owns its elements, it will automatically free the old value }
        fvalues[pos]:=val;
      end;
 

+ 1 - 4
compiler/llvm/nllvmtcon.pas

@@ -163,15 +163,12 @@ implementation
 
 
   procedure tllvmtypedconstplaceholder.replace(ai: tai; d: tdef);
-    var
-      oldconst: tai_abstracttypedconst;
     begin
       if d<>def then
         internalerror(2015091002);
-      oldconst:=agginfo.aggai.replacevalueatpos(
+      agginfo.aggai.replacevalueatpos(
         tai_simpletypedconst.create(d,ai),pos
       );
-      oldconst.free;
     end;