aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/open_readonly_1.f9014
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/io/transfer.c3
4 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b39fb69..f63c8db 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2005-01-22 Thomas Koenig <Thomas.Koenig@online.de>
+ PR libfortran/19451
+ * open_readonly_1.f90: New test.
+
+2005-01-22 Thomas Koenig <Thomas.Koenig@online.de>
+
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 0000000..622a07d
--- /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 c2218fb..1296ab2 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-22 Thomas Koenig <Thomas.Koenig@online.de>
+
+ PR libfortran/19451
+ * io/transfer.c (finalize_transfer): Don't do anything if
+ there is an error condition.
+
2005-01-22 David Edelsohn <edelsohn@gnu.org>
PR libgfortran/19052
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 114ed92..1dcbc7f 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)