summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-06-11 21:11:28 -0700
committerFedor Indutny <fedor@indutny.com>2014-06-27 17:02:02 +0400
commita97bdef06d1451c39df3a4a46f85f285c552a9df (patch)
treef1da99366f68ac7b215362933e3b4bc069308110 /lib
parentc94afdccf32443c9dd5a351fdfe1f19906327138 (diff)
downloadnode-a97bdef06d1451c39df3a4a46f85f285c552a9df.tar.gz
zlib: do not crash on write after close
fix #7767 Signed-off-by: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/zlib.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/zlib.js b/lib/zlib.js
index a1896baeb..c72ab92dc 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -320,6 +320,7 @@ function Zlib(opts, mode) {
util.inherits(Zlib, Transform);
Zlib.prototype.reset = function reset() {
+ assert(!this._closed, 'zlib binding closed');
return this._binding.reset();
};
@@ -394,6 +395,8 @@ Zlib.prototype._transform = function(chunk, encoding, cb) {
var availOutBefore = this._chunkSize - this._offset;
var inOff = 0;
+ if (this._closed)
+ return cb(new Error('zlib binding closed'));
var req = this._binding.write(flushFlag,
chunk, // in
inOff, // in_off
@@ -435,6 +438,7 @@ Zlib.prototype._transform = function(chunk, encoding, cb) {
inOff += (availInBefore - availInAfter);
availInBefore = availInAfter;
+ assert(!self._closed, 'zlib binding closed');
var newReq = self._binding.write(flushFlag,
chunk,
inOff,