This repository has been archived by the owner. It is now read-only.

simple fix for #2364 (zlib inflate/deflate/gunzip/gzip crashes when called on non-string input) #2385

wants to merge 4 commits into


None yet
4 participants

The bug symptom is that calling any of the zlib convenience methods with a non-string argument results in a crash.

The zlibBuffer function is calling removeListener without passing in the event listener itself.

This patch saves the event listeners in variables, and passes them to removeListener.


bnoordhuis commented Dec 22, 2011

@isaacs: You know the zlib code best. Can you review this patch when you're back?

Any word on if/when this patch will be reviewed? Thanks!

isaacs commented Jan 20, 2012

@nlacasse I don't get what this is doing. Can you include a test that fails without the patch, and passes with it?

Also, please prefer named function declarations like function onError() { rather than function expressions assigned to a variable like var onError = function() {.

@isaacs I changed the function declarations as you asked, and I added a test.

The issue is that zlib is not calling "removeListener" correctly. So on an error (like that caused by invalid input), removeListener gets called improperly and throws an error. The expected behavior is for a useful error to be passed to the callback.


piscisaureus commented Jan 20, 2012

@nlacasse Can you sign the CLA?


piscisaureus commented Jan 20, 2012

I made some minor edits and squashed everything. When the cla is signed we can land

@piscisaureus CLA is signed. Thanks!

isaacs commented Jan 20, 2012

Landed on 40c9348. Thanks!

@isaacs isaacs closed this Jan 20, 2012


piscisaureus commented Jan 21, 2012

The related commit incorrectly references #2365. Adding backreference.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.