aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorBud Davis <bdavis9659@comcast.net>2004-08-21 11:20:29 +0000
committerPaul Brook <pbrook@gcc.gnu.org>2004-08-21 11:20:29 +0000
commit0fa1b65cad6cb3ccbf48f992e1710a6953604842 (patch)
tree0aa7c855dd9dab30240c940a6ba4ab0f044510d7 /libgfortran
parentbe2043db430c362c56607a0538b8c8823799f44f (diff)
downloadgcc-0fa1b65cad6cb3ccbf48f992e1710a6953604842.zip
gcc-0fa1b65cad6cb3ccbf48f992e1710a6953604842.tar.gz
gcc-0fa1b65cad6cb3ccbf48f992e1710a6953604842.tar.bz2
re PR libfortran/16908 (Segfault in libgfortran/io/transfer.c)
2004-08-21 Bud Davis <bdavis9659@comcast.net> PR 16908 * io/transfer.c (next_record_w): Do not blank pad. * io/transfer.c (next_record): Take into account partial records. testsuite/ * gfortran.dg/direct_io.f90: New test. From-SVN: r86361
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/io/transfer.c16
2 files changed, 18 insertions, 4 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index ff4e945..46d5061 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2004-08-21 Bud Davis <bdavis9659@comcast.net>
+
+ PR 16908
+ * io/transfer.c (next_record_w): Do not blank pad.
+ * io/transfer.c (next_record): Take into account partial records.
+
2004-08-18 Victor Leikehman <lei@il.ibm.com>
PR fortran/13278
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index d4bec91..5bc3c00 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -1223,20 +1223,23 @@ next_record_w (int done)
switch (current_mode ())
{
case FORMATTED_DIRECT:
- case UNFORMATTED_DIRECT:
if (current_unit->bytes_left == 0)
break;
length = current_unit->bytes_left;
-
p = salloc_w (current_unit->s, &length);
+
if (p == NULL)
goto io_error;
memset (p, ' ', current_unit->bytes_left);
if (sfree (current_unit->s) == FAILURE)
goto io_error;
+ break;
+ case UNFORMATTED_DIRECT:
+ if (sfree (current_unit->s) == FAILURE)
+ goto io_error;
break;
case UNFORMATTED_SEQUENTIAL:
@@ -1304,6 +1307,7 @@ next_record_w (int done)
void
next_record (int done)
{
+ gfc_offset fp; /* file position */
current_unit->read_bad = 0;
@@ -1314,8 +1318,12 @@ next_record (int done)
current_unit->current_record = 0;
if (current_unit->flags.access == ACCESS_DIRECT)
- current_unit->last_record = file_position (current_unit->s)
- / current_unit->recl;
+ {
+ fp = file_position (current_unit->s);
+ /* Calculate next record, rounding up partial records. */
+ current_unit->last_record = (fp + curren_unit->recl - 1)
+ / current_unit->recl;
+ }
else
current_unit->last_record++;