From b573c98e24c2ab910b98fe59f5cf601a5940f1c3 Mon Sep 17 00:00:00 2001 From: pbrook Date: Sun, 23 Jan 2005 02:18:33 +0000 Subject: [PATCH] 2005-01-22 Thomas Koenig PR libfortran/19451 * io/transfer.c (finalize_transfer): Don't do anything if there is an error condition. * open_readonly_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94101 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/open_readonly_1.f90 | 14 ++++++++++++++ libgfortran/ChangeLog | 6 ++++++ libgfortran/io/transfer.c | 3 +++ 4 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/open_readonly_1.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b39fb693f0c..f63c8dba206 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2005-01-22 Thomas Koenig + PR libfortran/19451 + * open_readonly_1.f90: New test. + +2005-01-22 Thomas Koenig + PR libfortran/18982 * gfortran.dg/open_new.f90: New file. diff --git a/gcc/testsuite/gfortran.dg/open_readonly_1.f90 b/gcc/testsuite/gfortran.dg/open_readonly_1.f90 new file mode 100644 index 00000000000..622a07d2aee --- /dev/null +++ b/gcc/testsuite/gfortran.dg/open_readonly_1.f90 @@ -0,0 +1,14 @@ +! { dg-do run } +! PR19451 +! Writing to a non-empty readonly file caused a segfault. +! We were still trying to write the EOR after an error ocurred +program prog + open (unit=10, file='PR19451.dat') + write (10,*) "Hello World" + close (10) + open (unit=10, file='PR19451.dat', action="read") + write (10,*,err=20) "Hello World" + call abort() + 20 continue +end program + diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index c2218fba717..1296ab2a247 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2005-01-22 Thomas Koenig + + PR libfortran/19451 + * io/transfer.c (finalize_transfer): Don't do anything if + there is an error condition. + 2005-01-22 David Edelsohn PR libgfortran/19052 diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 114ed92abb9..1dcbc7ff74c 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -1389,6 +1389,9 @@ next_record (int done) static void finalize_transfer (void) { + if (ioparm.library_return != LIBRARY_OK) + return; + if ((ionml != NULL) && (ioparm.namelist_name != NULL)) { if (ioparm.namelist_read_mode) -- 2.11.4.GIT