diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-30 23:53:28 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-30 23:53:28 +0000 |
commit | 3cee6a22c07abe0c60331b860c9fac3388bb72a1 (patch) | |
tree | fdbf949686d1466d6782bfb1fda68ef5f80e95cb /test/zlib/test_zlib.rb | |
parent | b6c425aaddd38fec6a6b6f0d816bff18bc205cfd (diff) | |
download | ruby-3cee6a22c07abe0c60331b860c9fac3388bb72a1.tar.gz |
zlib: GzipReader#rewind preserves ZSTREAM_FLAG_GZFILE
* ext/zlib/zlib.c (gzfile_reset): preserve ZSTREAM_FLAG_GZFILE
[Bug #10101]
* test/zlib/test_zlib.rb (test_rewind): test each_byte
We must preserve the ZSTREAM_FLAG_GZFILE flag to prevent
zstream_detach_buffer from:
a) returning Qnil and breaking out of the `each_byte' loop
b) yielding a large string to each_byte
Note: the test case in bug report takes a long time. I found this
bug because I noticed the massive time descrepancy between
`each_byte' and `readbyte' loop before this patch. With this patch,
`each_byte' and `readbyte' both take very long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/zlib/test_zlib.rb')
-rw-r--r-- | test/zlib/test_zlib.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index f381b2ec0d..a7fa943c7a 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -695,6 +695,11 @@ if defined? Zlib assert_equal("foo", f.read) f.rewind assert_equal("foo", f.read) + + f.rewind + bytes = [] + f.each_byte { |b| bytes << b } + assert_equal "foo".bytes.to_a, bytes, '[Bug #10101]' end open(t.path, "rb") do |f| gz = Zlib::GzipReader.new(f) |