diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-10 02:40:45 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-10 02:40:45 +0000 |
commit | a935fe6faeb6c5403faa1d1a2532a426dce50602 (patch) | |
tree | 1d897bb4946e8a0dc0a1a56902a4c210c0627dea /test | |
parent | f012932218fd609f75f9268812df61fb26e2d0f1 (diff) |
merge revision(s) 58524,58525,58526,59333,59337: [Backport #13616]
zlib.c: zstream_expand_buffer_non_stream
* ext/zlib/zlib.c (zstream_expand_buffer_non_stream): rename from
zstream_expand_buffer_without_gvl() and replace duplicate code
in zstream_expand_buffer().
zlib.c: zstream_buffer_ungetbyte
* ext/zlib/zlib.c (zstream_buffer_ungetbyte): simplify by using
zstream_buffer_ungets().
zlib.c: no buf_filled in zstream
* ext/zlib/zlib.c (zstream): manage capacity and size of `buf`
instead of size and separated member `buf_filled`. reported by
Christian Jalio (jalio) at https://hackerone.com/reports/211958
Zlib::GzipReader#pos underflows after calling #ungetbyte or #ungetc at start of file [Bug #13616]
patched by Andrew Haines <andrew@haines.org.nz> [ruby-core:81488]
zlib.c: fix unnormalized Fixnum
* ext/zlib/zlib.c (rb_gzfile_total_out): cast to long not to
result in an unsigned long to normalized to Fixnum on LLP64
platforms. [ruby-core:81488]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/zlib/test_zlib.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 68acc72d9e..8ca14dafc8 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -127,6 +127,16 @@ if defined? Zlib assert_equal("foobar", Zlib::Inflate.inflate(s)) end + def test_expand_buffer; + z = Zlib::Deflate.new + src = "baz" * 1000 + z.avail_out = 1 + GC.stress = true + s = z.deflate(src, Zlib::FINISH) + GC.stress = false + assert_equal(src, Zlib::Inflate.inflate(s)) + end + def test_total z = Zlib::Deflate.new 1000.times { z << "foo" } @@ -653,6 +663,18 @@ if defined? Zlib } end + def test_ungetc_at_start_of_file + s = "".dup + w = Zlib::GzipWriter.new(StringIO.new(s)) + w << "abc" + w.close + r = Zlib::GzipReader.new(StringIO.new(s)) + + r.ungetc ?! + + assert_equal(-1, r.pos, "[ruby-core:81488][Bug #13616]") + end + def test_open Tempfile.create("test_zlib_gzip_reader_open") {|t| t.close |