Przeglądaj źródła

* fixed resetting of ansistrings

git-svn-id: trunk@2017 -
florian 19 lat temu
rodzic
commit
82a94db712
2 zmienionych plików z 21 dodań i 7 usunięć
  1. 4 1
      compiler/cgobj.pas
  2. 17 6
      compiler/nutils.pas

+ 4 - 1
compiler/cgobj.pas

@@ -1608,7 +1608,10 @@ implementation
          if is_ansistring(t) or
             is_widestring(t) or
             is_interfacecom(t) then
-            g_decrrefcount(list,t,ref)
+            begin
+              g_decrrefcount(list,t,ref);
+              a_load_const_ref(list,OS_ADDR,0,ref);
+            end
          else
            begin
               reference_reset_symbol(href,tstoreddef(t).get_rtti_label(initrtti),0);

+ 17 - 6
compiler/nutils.pas

@@ -466,23 +466,34 @@ implementation
 
 
     function finalize_data_node(p:tnode):tnode;
+      var
+        newstatement : tstatementnode;
       begin
         if not assigned(p.resulttype.def) then
           resulttypepass(p);
         if is_ansistring(p.resulttype.def) then
           begin
-            result:=ccallnode.createintern('fpc_ansistr_decr_ref',
+            result:=internalstatements(newstatement);
+            addstatement(newstatement,ccallnode.createintern('fpc_ansistr_decr_ref',
                   ccallparanode.create(
                     ctypeconvnode.create_internal(p,voidpointertype),
-                  nil));
+                  nil)));
+            addstatement(newstatement,cassignmentnode.create(
+               ctypeconvnode.create_internal(p.getcopy,voidpointertype),
+               cnilnode.create
+               ));
           end
-        else
-        if is_widestring(p.resulttype.def) then
+        else if is_widestring(p.resulttype.def) then
           begin
-            result:=ccallnode.createintern('fpc_widestr_decr_ref',
+            result:=internalstatements(newstatement);
+            addstatement(newstatement,ccallnode.createintern('fpc_widestr_decr_ref',
                   ccallparanode.create(
                     ctypeconvnode.create_internal(p,voidpointertype),
-                  nil));
+                  nil)));
+            addstatement(newstatement,cassignmentnode.create(
+               ctypeconvnode.create_internal(p.getcopy,voidpointertype),
+               cnilnode.create
+               ));
           end
         else
           result:=ccallnode.createintern('fpc_finalize',