From bad006f2e1b3117c431611eb352a1254f7d03e2d Mon Sep 17 00:00:00 2001 From: James Lal Date: Thu, 31 Mar 2016 14:16:30 -0700 Subject: [PATCH] zlib: fix use after null when calling .close An internal zlib error may cause _handle to be set to null. Close now will check if there is a _handle prior to calling .close on it. PR-URL: https://github.com/nodejs/node/pull/5982 Fixes: https://github.com/nodejs/node/issues/6034 Reviewed-By: Brian White Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- lib/zlib.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/zlib.js b/lib/zlib.js index 029c13a5f47cc6..d5c82f2fbba9ab 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -469,7 +469,9 @@ Zlib.prototype.close = function(callback) { this._closed = true; - this._handle.close(); + if (this._handle) { + this._handle.close(); + } process.nextTick(emitCloseNT, this); };