Skip to content

Commit c1970ef

Browse files
committed
tls: fix leak on invalid protocol method
1 parent 5bd2152 commit c1970ef

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/crypto/crypto_context.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,14 +1351,10 @@ SecureContext* SecureContext::Create(Environment* env) {
13511351
SecureContext::SecureContext(Environment* env, Local<Object> wrap)
13521352
: BaseObject(env, wrap) {
13531353
MakeWeak();
1354-
env->external_memory_accounter()->Increase(env->isolate(), kExternalSize);
13551354
}
13561355

13571356
inline void SecureContext::Reset() {
1358-
if (ctx_ != nullptr) {
1359-
env()->external_memory_accounter()->Decrease(env()->isolate(),
1360-
kExternalSize);
1361-
}
1357+
env()->external_memory_accounter()->Decrease(env()->isolate(), kExternalSize);
13621358
ctx_.reset();
13631359
cert_.reset();
13641360
issuer_.reset();
@@ -1469,6 +1465,8 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
14691465
if (!sc->ctx_) {
14701466
return ThrowCryptoError(env, ERR_get_error(), "SSL_CTX_new");
14711467
}
1468+
1469+
env->external_memory_accounter()->Increase(env->isolate(), kExternalSize);
14721470
SSL_CTX_set_app_data(sc->ctx_.get(), sc);
14731471

14741472
// Disable SSLv2 in the case when method == TLS_method() and the

0 commit comments

Comments
 (0)