Browse Source

* ensure that the file parameter for the Read/Write family of intrinsics is (and can be) freed in tinlinenode.handle_read_write()

git-svn-id: trunk@39565 -
svenbarth 7 years ago
parent
commit
781303c0d8
1 changed files with 4 additions and 3 deletions
  1. 4 3
      compiler/ninl.pas

+ 4 - 3
compiler/ninl.pas

@@ -1095,7 +1095,7 @@ implementation
             in_writeln_x:
               name:='fpc_writeln_end';
           end;
-          addstatement(Tstatementnode(newstatement),ccallnode.createintern(name,filepara));
+          addstatement(Tstatementnode(newstatement),ccallnode.createintern(name,filepara.getcopy));
         end;
       handle_text_read_write:=found_error;
     end;
@@ -1206,8 +1206,6 @@ implementation
           para := nextpara;
         end;
 
-      { free the file parameter }
-      filepara.free;
       handle_typed_read_write:=found_error;
     end;
 
@@ -1423,6 +1421,9 @@ implementation
         else
           found_error:=handle_text_read_write(filepara,Ttertiarynode(params),tnode(newstatement));
 
+        { free the file parameter (it's copied inside the handle_*_read_write methods) }
+        filepara.free;
+
         { if we found an error, simply delete the generated blocknode }
         if found_error then
           newblock.free