summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-29 15:38:39 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-29 15:38:39 +0000
commit3287030a0da850aff71c8d13cbbb28dc01e1136f (patch)
tree777f6d57a9e500963bbf8338c8f9872e171551ec /libgfortran
parentaa7e5a7047edf77a7b0e875ed5ab6e76df123911 (diff)
downloadgcc-3287030a0da850aff71c8d13cbbb28dc01e1136f.tar.gz
2015-08-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/67367 * io/unix.c (buf_read): Check for error condition and if found return the error code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227320 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/io/unix.c22
2 files changed, 22 insertions, 6 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 62db347978f..d08f050eb31 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2015-08-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libgfortran/67367
+ * io/unix.c (buf_read): Check for error condition and if found
+ return the error code.
+
2015-08-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* acinclude.m4: Remove LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT.
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index aa2feabebf0..fd5f2779021 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -518,16 +518,26 @@ buf_read (unix_stream * s, void * buf, ssize_t nbyte)
if (to_read <= BUFFER_SIZE/2)
{
did_read = raw_read (s, s->buffer, BUFFER_SIZE);
- s->physical_offset += did_read;
- s->active = did_read;
- did_read = (did_read > to_read) ? to_read : did_read;
- memcpy (p, s->buffer, did_read);
+ if (likely (did_read >= 0))
+ {
+ s->physical_offset += did_read;
+ s->active = did_read;
+ did_read = (did_read > to_read) ? to_read : did_read;
+ memcpy (p, s->buffer, did_read);
+ }
+ else
+ return did_read;
}
else
{
did_read = raw_read (s, p, to_read);
- s->physical_offset += did_read;
- s->active = 0;
+ if (likely (did_read >= 0))
+ {
+ s->physical_offset += did_read;
+ s->active = 0;
+ }
+ else
+ return did_read;
}
nbyte = did_read + nread;
}