Skip to content

Fix SIGSEGV in Deflate#params when called before any output - #144

Open
SAY-5 wants to merge 1 commit into
ruby:masterfrom
SAY-5:fix-deflate-params-segv
Open

Fix SIGSEGV in Deflate#params when called before any output#144
SAY-5 wants to merge 1 commit into
ruby:masterfrom
SAY-5:fix-deflate-params-segv

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 25, 2026

Copy link
Copy Markdown

Deflate#params crashes the interpreter when called on a stream that has not produced any output yet, because z->buf is still Qnil at that point and rb_str_set_len is called on it unconditionally. When no bytes were flushed filled is 0 and there is nothing to append, so guard the final rb_str_set_len with a NIL_P(z->buf) check, matching the guards already used throughout the file. Added a regression test that calls params before any output. Fixes #143.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
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.

Zlib::Deflate#params segfaults when called before any output buffer exists

1 participant