From b983f01d57d71defadcf986a891f9f00952c51eb Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 13 Aug 2026 21:40:57 +1200 Subject: [PATCH 1/2] Test invalid gzip compression levels --- test/zlib/test_zlib.rb | 2 ++ 1 file changed, 2 insertions(+) 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 From e86b4c63488fbb9aef3a505e0912a97d1467855c Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 13 Aug 2026 22:45:45 +1200 Subject: [PATCH 2/2] Initialize zstream state --- ext/zlib/zlib.c | 1 + 1 file changed, 1 insertion(+) 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; }