Skip to content

Commit 7fa24d6

Browse files
committed
tls_wrap: Unlink TLSWrap and SecureContext objects asap.
1 parent b4ad5d7 commit 7fa24d6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/_tls_wrap.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,22 @@ TLSSocket.prototype._wrapHandle = function(handle) {
289289
}
290290
});
291291

292-
this.on('close', this._destroySSL);
292+
this.on('close', function() {
293+
this._destroySSL();
294+
res = null;
295+
});
293296

294297
return res;
295298
};
296299

297300
TLSSocket.prototype._destroySSL = function _destroySSL() {
301+
if (!this.ssl) return;
298302
this.ssl.destroySSL();
299-
if (this.ssl._secureContext.singleUse)
303+
if (this.ssl._secureContext.singleUse) {
300304
this.ssl._secureContext.context.close();
305+
delete this.ssl._secureContext.context;
306+
}
307+
delete this.ssl;
301308
};
302309

303310
TLSSocket.prototype._init = function(socket, wrap) {

0 commit comments

Comments
 (0)