Skip to content

Patch seg fault in Zlib::Deflate.new.params(1, Zlib::FILTERED) - #192

Open
FletcherDares wants to merge 1 commit into
ruby:masterfrom
FletcherDares:fix/deflate-params-before-input
Open

FletcherDares wants to merge 1 commit into
ruby:masterfrom
FletcherDares:fix/deflate-params-before-input

Conversation

@FletcherDares

@FletcherDares FletcherDares commented Nov 20, 2026 •

Copy link
Copy Markdown

TL;DR

Fix a segfault when Zlib::Deflate#params is called before the first write. The call now applies the requested settings
and returns nil.

Context

A new deflate stream has no output buffer yet (z->buf == Qnil). deflateParams() can succeed without producing any
bytes, but the Ruby wrapper still calls RSTRING_LEN(z->buf) to update the buffer length. That access can segfault.

repro:

Zlib::Deflate.new.params(1, Zlib::FILTERED)

@FletcherDares FletcherDares changed the title patch seg fault in Zlib::Deflate.new.params(1, Zlib::FILTERED) Patch seg fault in Zlib::Deflate.new.params(1, Zlib::FILTERED) Nov 20, 2026
@FletcherDares
FletcherDares marked this pull request as ready for review November 20, 2026 00:51

This branch has not been deployed

No deployments
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.

1 participant