зеркало из https://github.com/github/ruby.git
* io.c (rb_io_each_byte): rbuf can be refreshed during yield.
[Bug #5119] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
cf310f9741
Коммит
321346cfa5
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Jul 30 23:14:44 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (rb_io_each_byte): rbuf can be refreshed during yield.
|
||||||
|
[Bug #5119]
|
||||||
|
|
||||||
Sat Jul 30 22:35:50 2011 Naohisa Goto <ngotogenome@gmail.com>
|
Sat Jul 30 22:35:50 2011 Naohisa Goto <ngotogenome@gmail.com>
|
||||||
|
|
||||||
* strftime.c (NEEDS): avoid SEGV due to integer overflow in
|
* strftime.c (NEEDS): avoid SEGV due to integer overflow in
|
||||||
|
|
9
io.c
9
io.c
|
@ -2829,13 +2829,10 @@ rb_io_each_byte(VALUE io)
|
||||||
GetOpenFile(io, fptr);
|
GetOpenFile(io, fptr);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
p = fptr->rbuf.ptr+fptr->rbuf.off;
|
while (fptr->rbuf.len > 0) {
|
||||||
e = p + fptr->rbuf.len;
|
p = fptr->rbuf.ptr + fptr->rbuf.off++;
|
||||||
while (p < e) {
|
e = p + fptr->rbuf.len--;
|
||||||
fptr->rbuf.off++;
|
|
||||||
fptr->rbuf.len--;
|
|
||||||
rb_yield(INT2FIX(*p & 0xff));
|
rb_yield(INT2FIX(*p & 0xff));
|
||||||
p++;
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
}
|
}
|
||||||
rb_io_check_byte_readable(fptr);
|
rb_io_check_byte_readable(fptr);
|
||||||
|
|
|
@ -235,6 +235,16 @@ class TestIO < Test::Unit::TestCase
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_each_byte_with_seek
|
||||||
|
t = make_tempfile
|
||||||
|
bug5119 = '[ruby-core:38609]'
|
||||||
|
i = 0
|
||||||
|
open(t.path) do |f|
|
||||||
|
f.each_byte {i = f.pos}
|
||||||
|
end
|
||||||
|
assert_equal(12, i, bug5119)
|
||||||
|
end
|
||||||
|
|
||||||
def test_each_codepoint
|
def test_each_codepoint
|
||||||
t = make_tempfile
|
t = make_tempfile
|
||||||
bug2959 = '[ruby-core:28650]'
|
bug2959 = '[ruby-core:28650]'
|
||||||
|
|
Загрузка…
Ссылка в новой задаче