diff options
author | Dan Corman <dan.corman@gmail.com> | 2018-11-06 16:54:47 +0000 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-11-14 20:40:36 -0800 |
commit | 4e6d28a710f1b11ddc15cceba0863c9b0d6f06c6 (patch) | |
tree | 6fe26ff2debaa82381f553af04a545fc6940987b /lib | |
parent | 9ca5c525f4cda44112b93f20d22353759eabb807 (diff) | |
download | android-node-v8-4e6d28a710f1b11ddc15cceba0863c9b0d6f06c6.tar.gz android-node-v8-4e6d28a710f1b11ddc15cceba0863c9b0d6f06c6.tar.bz2 android-node-v8-4e6d28a710f1b11ddc15cceba0863c9b0d6f06c6.zip |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zlib.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/zlib.js b/lib/zlib.js index c833afff14..559f6c2d5f 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -350,8 +350,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; @@ -507,8 +506,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. @@ -545,8 +544,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; @@ -593,8 +591,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) { |