Hi, the attached patch fixes PR 64770, by checking whether a string is a null pointer before calling strdup() on it. Committed r220086 as obvious.
libgfortran ChangeLog: 2015-01-24 Janne Blomqvist <j...@gcc.gnu.org> PR libfortran/64770 * io/unit.c (filename_from_unit): Check that u->filename != NULL before calling strdup. testsuite ChangeLog: 2015-01-24 Janne Blomqvist <j...@gcc.gnu.org> PR libfortran/64770 * gfortran.dg/open_new_segv.f90: New test. diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index e168d32..687f507 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -829,7 +829,7 @@ filename_from_unit (int n) } /* Get the filename. */ - if (u != NULL) + if (u != NULL && u->filename != NULL) return strdup (u->filename); else return (char *) NULL; -- Janne Blomqvist