Skip to content

Commit 5c2c5b9

Browse files
dYalecodebytere
authored andcommitted
lib: improved conditional check in zlib
PR-URL: #24190 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 6cad1b6 commit 5c2c5b9

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
@@ -347,8 +347,7 @@ Object.defineProperty(Zlib.prototype, 'bytesRead', {
347347
// `params()` function should not happen while a write is currently in progress
348348
// on the threadpool.
349349
function paramsAfterFlushCallback(level, strategy, callback) {
350-
if (!this._handle)
351-
assert(false, 'zlib binding closed');
350+
assert(this._handle, 'zlib binding closed');
352351
this._handle.params(level, strategy);
353352
if (!this._hadError) {
354353
this._level = level;
@@ -504,8 +503,8 @@ function processChunkSync(self, chunk, flushFlag) {
504503
else
505504
buffers.push(out);
506505
nread += out.byteLength;
507-
} else if (have < 0) {
508-
assert(false, 'have should not go down');
506+
} else {
507+
assert(have === 0, 'have should not go down');
509508
}
510509

511510
// exhausted the output buffer, or used all the input create a new one.
@@ -542,8 +541,7 @@ function processChunkSync(self, chunk, flushFlag) {
542541

543542
function processChunk(self, chunk, flushFlag, cb) {
544543
var handle = self._handle;
545-
if (!handle)
546-
assert(false, 'zlib binding closed');
544+
assert(handle, 'zlib binding closed');
547545

548546
handle.buffer = chunk;
549547
handle.cb = cb;
@@ -590,8 +588,8 @@ function processCallback() {
590588
var out = self._outBuffer.slice(self._outOffset, self._outOffset + have);
591589
self._outOffset += have;
592590
self.push(out);
593-
} else if (have < 0) {
594-
assert(false, 'have should not go down');
591+
} else {
592+
assert(have === 0, 'have should not go down');
595593
}
596594

597595
if (self.destroyed) {

0 commit comments

Comments
 (0)