Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zlib: fix assert fail for bad write in object mode #16960

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ function flushCallback(level, strategy, callback) {
// true or false if there is anything in the queue when
// you call the .write() method.
function Zlib(opts, mode) {
Transform.call(this, opts);
var chunkSize = Z_DEFAULT_CHUNK;
var flush = Z_NO_FLUSH;
var finishFlush = Z_FINISH;
Expand Down Expand Up @@ -257,6 +256,7 @@ function Zlib(opts, mode) {
opts.writableObjectMode = false;
}
}
Transform.call(this, opts);
this.bytesRead = 0;
this._handle = new binding.Zlib(mode);
this._handle.jsref = this; // Used by processCallback() and zlibOnError()
Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-zlib-object-write.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

require('../common');
const assert = require('assert');
const { Gunzip } = require('zlib');

const gunzip = new Gunzip({ objectMode: true });
assert.throws(
() => gunzip.write({}),
TypeError
);