Browse Source

* Corrected label reference counts caused by TAsmLabel.GetName incrementing refs

J. Gareth "Curious Kit" Moreton 3 years ago
parent
commit
f6c741ee73
3 changed files with 12 additions and 9 deletions
  1. 0 9
      compiler/aasmbase.pas
  2. 8 0
      compiler/aasmcnst.pas
  3. 4 0
      compiler/objcgutl.pas

+ 0 - 9
compiler/aasmbase.pas

@@ -225,8 +225,6 @@ interface
        TAsmSymbolClass = class of TAsmSymbol;
 
        TAsmLabel = class(TAsmSymbol)
-       protected
-         function getname:TSymStr;override;
          {$push}{$warnings off}
          { new visibility section to let "warnings off" take effect }
        protected
@@ -424,13 +422,6 @@ implementation
       end;
 
 
-    function TAsmLabel.getname:TSymStr;
-      begin
-        getname:=inherited getname;
-        increfs;
-      end;
-
-
     constructor TAsmLabel.create_non_global(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType; const prefix: TSymStr);
       var
         asmtyp: TAsmsymtype;

+ 8 - 0
compiler/aasmcnst.pas

@@ -1061,6 +1061,9 @@ implementation
              sec_rodata,
              indsecname,
              ptrdef.alignment));
+
+           symind.increfs;
+
            indtcb.free;
            if not (target_info.system in systems_indirect_var_imports) then
              current_module.add_public_asmsym(symind.name,AB_INDIRECT,AT_DATA);
@@ -1470,6 +1473,7 @@ implementation
              so we keep the difference depending on whether the original was
              allocated via getstatic/getlocal/getglobal datalabel) }
            startlab:=tasmlabel.create(current_asmdata.AsmSymbolDict,startlab.name+'$strlab',startlab.bind,startlab.typ);
+           startlab.increfs;
          end;
        { sanity check }
        if result.ofs<>string_symofs then
@@ -1738,6 +1742,7 @@ implementation
                { allocate a separate label for the start of the data (see
                  emit_string_const_common() for explanation) }
                startlab:=tasmlabel.create(current_asmdata.AsmSymbolDict,startlab.name+'$strlab',startlab.bind,startlab.typ);
+               startlab.increfs;
              end
            else
              internalerror(2015031502);
@@ -1802,6 +1807,7 @@ implementation
              so we keep the difference depending on whether the original was
              allocated via getstatic/getlocal/getglobal datalabel) }
            startlab:=tasmlabel.create(current_asmdata.AsmSymbolDict,startlab.name+'$dynarrlab',startlab.bind,startlab.typ);
+           startlab.increfs;
          end;
        { sanity check }
        if result.ofs<>dynarray_symofs then
@@ -1945,6 +1951,8 @@ implementation
            strtcb.free;
 
            entry^.Data:=strlab;
+           { Make sure strlab has a reference }
+           strlab.increfs;
          end
        else
          strlab:=tasmlabel(entry^.Data);

+ 4 - 0
compiler/objcgutl.pas

@@ -163,6 +163,10 @@ procedure objcreatestringpoolentryintern(p: pchar; len: longint; pooltype: tcons
         { create new entry }
         current_asmdata.getlabel(strlab,alt_data);
         entry^.Data:=strlab;
+
+        { Make sure strlab has a reference }
+        strlab.increfs;
+
         getmem(pc,entry^.keylength+1);
         move(entry^.key^,pc^,entry^.keylength);
         pc[entry^.keylength]:=#0;