joyent/node — Issue #2384: zlib inflate/deflate/gunzip/gzip crashes when called on non-string input
Author: nlacasse
Created: 2011-12-20 01:02:36+00:00
State: open

Node v0.6.6 on Linux

Calling any of the zlib "convenience methods" (inflate, deflate, inflateRaw, deflateRaw, gzip, gunzip, gzipRaw, gunzipRaw) with a non-string input results an uncaught error about removeListener.

For example:
zlib.gunzip(1, function (err, result) {
console.log(err);
});

Expected:
"Invalid argument" error should be logged.

Actual:
Error: removeListener only takes instances of Function
at Gzip.removeListener (events.js:165:11)
at Gzip. (zlib.js:126:12)
at Gzip.emit (events.js:67:17)
at Gzip.write (zlib.js:291:17)
at zlibBuffer (zlib.js:158:10)
at Object.gzip (zlib.js:98:3)

It appears that zlibBuffer is not passing a function argument to removeListener on lines 165 and 166.