Skip to content

Commit

Permalink
lib: improved conditional check in zlib
Browse files Browse the repository at this point in the history
PR-URL: #24190
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
dYale authored and codebytere committed Jan 12, 2019
1 parent 6cad1b6 commit 5c2c5b9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ Object.defineProperty(Zlib.prototype, 'bytesRead', {
// `params()` function should not happen while a write is currently in progress
// on the threadpool.
function paramsAfterFlushCallback(level, strategy, callback) {
if (!this._handle)
assert(false, 'zlib binding closed');
assert(this._handle, 'zlib binding closed');
this._handle.params(level, strategy);
if (!this._hadError) {
this._level = level;
Expand Down Expand Up @@ -504,8 +503,8 @@ function processChunkSync(self, chunk, flushFlag) {
else
buffers.push(out);
nread += out.byteLength;
} else if (have < 0) {
assert(false, 'have should not go down');
} else {
assert(have === 0, 'have should not go down');
}

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

function processChunk(self, chunk, flushFlag, cb) {
var handle = self._handle;
if (!handle)
assert(false, 'zlib binding closed');
assert(handle, 'zlib binding closed');

handle.buffer = chunk;
handle.cb = cb;
Expand Down Expand Up @@ -590,8 +588,8 @@ function processCallback() {
var out = self._outBuffer.slice(self._outOffset, self._outOffset + have);
self._outOffset += have;
self.push(out);
} else if (have < 0) {
assert(false, 'have should not go down');
} else {
assert(have === 0, 'have should not go down');
}

if (self.destroyed) {
Expand Down

0 comments on commit 5c2c5b9

Please sign in to comment.