Skip to content

Commit 5ca0cf7

Browse files
dYaleBridgeAR
authored andcommitted
lib: improved conditional check in zlib
PR-URL: #24190 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 5b9ef11 commit 5ca0cf7

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/zlib.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ Object.defineProperty(Zlib.prototype, 'bytesRead', {
350350
// `params()` function should not happen while a write is currently in progress
351351
// on the threadpool.
352352
function paramsAfterFlushCallback(level, strategy, callback) {
353-
if (!this._handle)
354-
assert(false, 'zlib binding closed');
353+
assert(this._handle, 'zlib binding closed');
355354
this._handle.params(level, strategy);
356355
if (!this._hadError) {
357356
this._level = level;
@@ -507,8 +506,8 @@ function processChunkSync(self, chunk, flushFlag) {
507506
else
508507
buffers.push(out);
509508
nread += out.byteLength;
510-
} else if (have < 0) {
511-
assert(false, 'have should not go down');
509+
} else {
510+
assert(have === 0, 'have should not go down');
512511
}
513512

514513
// exhausted the output buffer, or used all the input create a new one.
@@ -545,8 +544,7 @@ function processChunkSync(self, chunk, flushFlag) {
545544

546545
function processChunk(self, chunk, flushFlag, cb) {
547546
var handle = self._handle;
548-
if (!handle)
549-
assert(false, 'zlib binding closed');
547+
assert(handle, 'zlib binding closed');
550548

551549
handle.buffer = chunk;
552550
handle.cb = cb;
@@ -593,8 +591,8 @@ function processCallback() {
593591
var out = self._outBuffer.slice(self._outOffset, self._outOffset + have);
594592
self._outOffset += have;
595593
self.push(out);
596-
} else if (have < 0) {
597-
assert(false, 'have should not go down');
594+
} else {
595+
assert(have === 0, 'have should not go down');
598596
}
599597

600598
if (self.destroyed) {

0 commit comments

Comments
 (0)