summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/io.c b/io.c
index cac35eb7e6..28504c9197 100644
--- a/io.c
+++ b/io.c
@@ -790,6 +790,7 @@ read_all(fptr, siz, str)
n = rb_io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr->f);
if (pos > 0 && n == 0 && bytes == 0) {
rb_str_resize(str,0);
+ if (!fptr->f) return Qnil;
if (feof(fptr->f)) return Qnil;
if (!ferror(fptr->f)) return str;
rb_sys_fail(fptr->path);
@@ -843,6 +844,7 @@ io_read(argc, argv, io)
n = rb_io_fread(RSTRING(str)->ptr, len, fptr->f);
if (n == 0) {
rb_str_resize(str,0);
+ if (!fptr->f) return Qnil;
if (feof(fptr->f)) return Qnil;
if (len > 0) rb_sys_fail(fptr->path);
}