This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fortran: PR/34908, PR/36276: do not free current_file->filename if it changes


Hi,

The "old" current_file->filename is referenced by linemap, thus it
cannot be freed at this point. The proper fix probably would be to
update linemap with the new filename, but in any case this trivial
patch is an improvement. This change is already suggested by a comment
in PR/36276, I arrived at it independently by investigating PR/34908.
Bootstrapped/regtested Fortran on trunk on x86_64-unknown-linux-gnu,
OK for trunk? OK for 4.3 branch after bootstrapping/regtesting there?

2008-06-20  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

        PR fortran/34908, fortran/36276
        * scanner.c (preprocessor_line):  Do not call gfc_free for
        current_file->filename if it differs from filename.

-- 
Laurynas


Index: gcc/fortran/scanner.c
===================================================================
--- gcc/fortran/scanner.c	(revision 136912)
+++ gcc/fortran/scanner.c	(working copy)
@@ -1654,7 +1654,9 @@

   if (strcmp (current_file->filename, filename) != 0)
     {
-      gfc_free (current_file->filename);
+       /* FIXME: we leak the old filename because a pointer to it may be stored
+          in the linemap.  Alternative could be using GC or updating linemap to
+          point to the new name, but there is no API for that currently. */
       current_file->filename = gfc_getmem (strlen (filename) + 1);
       strcpy (current_file->filename, filename);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]