Commit 7165d8f1 by Janne Blomqvist

PR libfortran/64770 Segfault when trying to open existing file with status="new".

libgfortran ChangeLog:

2015-01-24  Janne Blomqvist  <jb@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  <jb@gcc.gnu.org>

	PR libfortran/64770
	* gfortran.dg/open_new_segv.f90: New test.

From-SVN: r220086
parent d773ed85
2015-01-24 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/64770
* gfortran.dg/open_new_segv.f90: New test.
2015-01-24 Oleg Endo <olegendo@gcc.gnu.org> 2015-01-24 Oleg Endo <olegendo@gcc.gnu.org>
PR target/49263 PR target/49263
......
! { dg-do run }
! PR 64770 SIGSEGV when trying to open an existing file with status="new"
program pr64770
implicit none
! Make sure pr64770test.dat exists
open(99, file="pr64770test.dat", status="replace")
close(99)
open(99, file="pr64770test.dat", access="stream", form="unformatted", &
status="new")
end program pr64770
2015-01-24 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/64770
* io/unit.c (filename_from_unit): Check that u->filename != NULL
before calling strdup.
2015-01-22 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2015-01-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/61933 PR libgfortran/61933
......
...@@ -829,7 +829,7 @@ filename_from_unit (int n) ...@@ -829,7 +829,7 @@ filename_from_unit (int n)
} }
/* Get the filename. */ /* Get the filename. */
if (u != NULL) if (u != NULL && u->filename != NULL)
return strdup (u->filename); return strdup (u->filename);
else else
return (char *) NULL; return (char *) NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment