Skip to content

Initialize zstream state - #141

Merged
ioquatix merged 2 commits into
ruby:masterfrom
samuel-williams-shopify:fix/gzip-invalid-level
Aug 13, 2026
Merged

Initialize zstream state#141
ioquatix merged 2 commits into
ruby:masterfrom
samuel-williams-shopify:fix/gzip-invalid-level

Conversation

@samuel-williams-shopify

@samuel-williams-shopify samuel-williams-shopify commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Calling Zlib.gzip with an invalid compression level should raise Zlib::StreamError, consistently with Zlib::Deflate and Zlib::GzipWriter.

On several Ruby/platform combinations, the failed deflateInit2 call leaves z_stream.state uninitialized. The subsequent gzip cleanup can then pass that invalid pointer into deflate, causing a segmentation fault.

This initializes z_stream.state to Z_NULL and adds a regression test for the invalid-level path.

The failure was originally observed here:

https://github.com/socketry/protocol-grpc/actions/runs/31685751610/job/94401275917?pr=7

@samuel-williams-shopify samuel-williams-shopify changed the title Test invalid gzip compression levels Initialize zstream state Aug 13, 2026

@ioquatix ioquatix left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ioquatix
ioquatix merged commit ef86fba into ruby:master Aug 13, 2026
30 checks passed
matzbot pushed a commit to ruby/ruby that referenced this pull request Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants