Skip to content

Commit c7fef3d

Browse files
lightsofapolloaddaleax
authored andcommitted
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: #5982 Fixes: #6034 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent e38bade commit c7fef3d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/zlib.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,10 @@ function _close(engine, callback) {
474474

475475
engine._closed = true;
476476

477-
engine._handle.close();
477+
// Caller may invoke .close after a zlib error (which will null _handle).
478+
if (engine._handle) {
479+
engine._handle.close();
480+
}
478481
}
479482

480483
function emitCloseNT(self) {

0 commit comments

Comments
 (0)