From e6e25b794d8db52e1df85a02f28846ad7eb82d49 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 18 Sep 2021 16:07:30 +0900 Subject: merge revision(s) 13939d61b4b69bd109c5f41303c79868d639fa44: [Backport #17661] Check if closed after each yield [Bug #17661] --- io.c | 4 +++- test/ruby/test_io.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) --- io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'io.c') diff --git a/io.c b/io.c index bc31c7bffd..521b0b0e9a 100644 --- a/io.c +++ b/io.c @@ -3994,9 +3994,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; @@ -4215,6 +4215,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); @@ -4252,6 +4253,7 @@ rb_io_each_codepoint(VALUE io) else { continue; } + rb_io_check_byte_readable(fptr); } return io; -- cgit v1.2.3