Skip to content

Commit

Permalink
src: fix Get() usage in tls_wrap.cc
Browse files Browse the repository at this point in the history
PR-URL: #24060
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
cjihrig authored and BridgeAR committed Nov 13, 2018
1 parent 9437aaa commit 2a93882
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,22 @@ void TLSWrap::SSLInfoCallback(const SSL* ssl_, int where, int ret) {
Local<Object> object = c->object();

if (where & SSL_CB_HANDSHAKE_START) {
Local<Value> callback = object->Get(env->onhandshakestart_string());
if (callback->IsFunction()) {
Local<Value> callback;

if (object->Get(env->context(), env->onhandshakestart_string())
.ToLocal(&callback) && callback->IsFunction()) {
Local<Value> argv[] = { env->GetNow() };
c->MakeCallback(callback.As<Function>(), arraysize(argv), argv);
}
}

if (where & SSL_CB_HANDSHAKE_DONE) {
Local<Value> callback;

c->established_ = true;
Local<Value> callback = object->Get(env->onhandshakedone_string());
if (callback->IsFunction()) {

if (object->Get(env->context(), env->onhandshakedone_string())
.ToLocal(&callback) && callback->IsFunction()) {
c->MakeCallback(callback.As<Function>(), 0, nullptr);
}
}
Expand Down Expand Up @@ -814,7 +819,10 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {

// Call the SNI callback and use its return value as context
Local<Object> object = p->object();
Local<Value> ctx = object->Get(env->sni_context_string());
Local<Value> ctx;

if (!object->Get(env->context(), env->sni_context_string()).ToLocal(&ctx))
return SSL_TLSEXT_ERR_NOACK;

// Not an object, probably undefined or null
if (!ctx->IsObject())
Expand Down

0 comments on commit 2a93882

Please sign in to comment.