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: nodejs#5982
Fixes: nodejs#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 joelostrowski committed Apr 25, 2016
1 parent 0324c24 commit 8dbd5c5
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 8dbd5c5

Please sign in to comment.