aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-06-27 09:42:01 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-06-27 11:18:41 +0900
commit13939d61b4b69bd109c5f41303c79868d639fa44 (patch)
tree5f96e396fb9667528767c04c590ef98096e1685f /io.c
parent35c7e83bb32869cd96112ffd850b02047b48fac1 (diff)
downloadruby-13939d61b4b69bd109c5f41303c79868d639fa44.tar.gz
Check if closed after each yield [Bug #17661]
Diffstat (limited to 'io.c')
-rw-r--r--io.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/io.c b/io.c
index 7f7d6e32e7..fa07f53b80 100644
--- a/io.c
+++ b/io.c
@@ -4052,9 +4052,9 @@ rb_io_each_byte(VALUE io)
char *p = fptr->rbuf.ptr + fptr->rbuf.off++;
fptr->rbuf.len--;
rb_yield(INT2FIX(*p & 0xff));
+ rb_io_check_byte_readable(fptr);
errno = 0;
}
- rb_io_check_byte_readable(fptr);
READ_CHECK(fptr);
} while (io_fillbuf(fptr) >= 0);
return io;
@@ -4271,6 +4271,7 @@ rb_io_each_codepoint(VALUE io)
fptr->cbuf.off += n;
fptr->cbuf.len -= n;
rb_yield(UINT2NUM(c));
+ rb_io_check_byte_readable(fptr);
}
}
NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr);
@@ -4308,6 +4309,7 @@ rb_io_each_codepoint(VALUE io)
else {
continue;
}
+ rb_io_check_byte_readable(fptr);
}
return io;