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 <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
lightsofapollo authored and addaleax committed Apr 19, 2016
1 parent e38bade commit c7fef3d
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 c7fef3d

Please sign in to comment.