Skip to content

Commit

Permalink
zlib: fix use after null when calling .close
Browse files Browse the repository at this point in the history
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: #5982
Fixes: #6034
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
lightsofapollo authored and jasnell committed Apr 26, 2016
1 parent c3ad97d commit bd944e3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,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) {
Expand Down

0 comments on commit bd944e3

Please sign in to comment.