summaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-24 03:51:24 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-24 03:51:24 +0000
commit30510b5b7cdfef8ec617921a10aeea5101972cc2 (patch)
tree6b79cd06e656c4d0572adf233e3348fe44ce4a2a /libgfortran/io
parent20cc58a121c90383cc4bffac906886cf1526589f (diff)
downloadgcc-30510b5b7cdfef8ec617921a10aeea5101972cc2.tar.gz
2005-10-23 Jerry DeLisle <jvdelisle@verizon.net>
PR libgfortran/24489 * io/transfer.c (read_block): Change the order of execution to not read past end-of-record. (read_block_direct): Same change. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105840 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/transfer.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 1d1b78b3740..efd8e9dde4f 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -248,10 +248,6 @@ read_block (int *length)
char *source;
int nread;
- if (current_unit->flags.form == FORM_FORMATTED &&
- current_unit->flags.access == ACCESS_SEQUENTIAL)
- return read_sf (length); /* Special case. */
-
if (current_unit->bytes_left < *length)
{
if (current_unit->flags.pad == PAD_NO)
@@ -262,6 +258,10 @@ read_block (int *length)
*length = current_unit->bytes_left;
}
+
+ if (current_unit->flags.form == FORM_FORMATTED &&
+ current_unit->flags.access == ACCESS_SEQUENTIAL)
+ return read_sf (length); /* Special case. */
current_unit->bytes_left -= *length;
@@ -295,15 +295,6 @@ read_block_direct (void * buf, size_t * nbytes)
void *data;
size_t nread;
- if (current_unit->flags.form == FORM_FORMATTED &&
- current_unit->flags.access == ACCESS_SEQUENTIAL)
- {
- length = (int*) nbytes;
- data = read_sf (length); /* Special case. */
- memcpy (buf, data, (size_t) *length);
- return;
- }
-
if (current_unit->bytes_left < *nbytes)
{
if (current_unit->flags.pad == PAD_NO)
@@ -315,6 +306,15 @@ read_block_direct (void * buf, size_t * nbytes)
*nbytes = current_unit->bytes_left;
}
+ if (current_unit->flags.form == FORM_FORMATTED &&
+ current_unit->flags.access == ACCESS_SEQUENTIAL)
+ {
+ length = (int*) nbytes;
+ data = read_sf (length); /* Special case. */
+ memcpy (buf, data, (size_t) *length);
+ return;
+ }
+
current_unit->bytes_left -= *nbytes;
nread = *nbytes;