lib: improved conditional check in zlib

PR-URL: https://github.com/nodejs/node/pull/24190
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Dan Corman 2018-11-06 16:54:47 +00:00 committed by Rich Trott
parent 9ca5c525f4
commit 4e6d28a710

View File

@ -350,8 +350,7 @@ Object.defineProperty(Zlib.prototype, 'bytesRead', {
// `params()` function should not happen while a write is currently in progress // `params()` function should not happen while a write is currently in progress
// on the threadpool. // on the threadpool.
function paramsAfterFlushCallback(level, strategy, callback) { function paramsAfterFlushCallback(level, strategy, callback) {
if (!this._handle) assert(this._handle, 'zlib binding closed');
assert(false, 'zlib binding closed');
this._handle.params(level, strategy); this._handle.params(level, strategy);
if (!this._hadError) { if (!this._hadError) {
this._level = level; this._level = level;
@ -507,8 +506,8 @@ function processChunkSync(self, chunk, flushFlag) {
else else
buffers.push(out); buffers.push(out);
nread += out.byteLength; nread += out.byteLength;
} else if (have < 0) { } else {
assert(false, 'have should not go down'); assert(have === 0, 'have should not go down');
} }
// exhausted the output buffer, or used all the input create a new one. // exhausted the output buffer, or used all the input create a new one.
@ -545,8 +544,7 @@ function processChunkSync(self, chunk, flushFlag) {
function processChunk(self, chunk, flushFlag, cb) { function processChunk(self, chunk, flushFlag, cb) {
var handle = self._handle; var handle = self._handle;
if (!handle) assert(handle, 'zlib binding closed');
assert(false, 'zlib binding closed');
handle.buffer = chunk; handle.buffer = chunk;
handle.cb = cb; handle.cb = cb;
@ -593,8 +591,8 @@ function processCallback() {
var out = self._outBuffer.slice(self._outOffset, self._outOffset + have); var out = self._outBuffer.slice(self._outOffset, self._outOffset + have);
self._outOffset += have; self._outOffset += have;
self.push(out); self.push(out);
} else if (have < 0) { } else {
assert(false, 'have should not go down'); assert(have === 0, 'have should not go down');
} }
if (self.destroyed) { if (self.destroyed) {