diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 481d74b..187e358 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -651,6 +651,7 @@ zstream_init(struct zstream *z, const struct zstream_funcs *func) z->stream.avail_in = 0; z->stream.next_out = Z_NULL; z->stream.avail_out = 0; + z->stream.state = Z_NULL; z->func = func; } diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 48b8f17..71159a0 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -1524,6 +1524,8 @@ def test_deflate_stream end def test_gzip + assert_raise(Zlib::StreamError) { Zlib.gzip("foo", level: 100) } + actual = Zlib.gzip("foo".freeze) actual[4, 4] = "\x00\x00\x00\x00" # replace mtime actual[9] = "\xff" # replace OS