From 094e34ecefe7fe24e8d9fbb03198f7a38fcaf1f6 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. --- lib/zlib.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/zlib.js b/lib/zlib.js index 79c78ea4a51307..f114ed31063081 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -467,7 +467,10 @@ function _close(engine, callback) { engine._closed = true; - engine._handle.close(); + // Caller may invoke .close after a zlib error (which will null _handle). + if (engine._handle) { + engine._handle.close(); + } } function emitCloseNT(self) {