From 7fa24d67acd8c83ee791d1452c1e3b8fc7869cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Sat, 2 May 2015 00:59:05 +0300 Subject: [PATCH] tls_wrap: Unlink TLSWrap and SecureContext objects asap. --- lib/_tls_wrap.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 95df8f56604682..c0edd0e752701a 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -289,15 +289,22 @@ TLSSocket.prototype._wrapHandle = function(handle) { } }); - this.on('close', this._destroySSL); + this.on('close', function() { + this._destroySSL(); + res = null; + }); return res; }; TLSSocket.prototype._destroySSL = function _destroySSL() { + if (!this.ssl) return; this.ssl.destroySSL(); - if (this.ssl._secureContext.singleUse) + if (this.ssl._secureContext.singleUse) { this.ssl._secureContext.context.close(); + delete this.ssl._secureContext.context; + } + delete this.ssl; }; TLSSocket.prototype._init = function(socket, wrap) {