Skip to content

Commit

Permalink
src: refactor CertCbDone to avoid goto statement
Browse files Browse the repository at this point in the history
PR-URL: #34325
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
tniessen authored and cjihrig committed Jul 22, 2020
1 parent 1f7194c commit ed01db6
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2495,10 +2495,6 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
env->sni_context_string()).ToLocalChecked();
Local<FunctionTemplate> cons = env->secure_context_constructor_template();

// Not an object, probably undefined or null
if (!ctx->IsObject())
goto fire_cb;

if (cons->HasInstance(ctx)) {
SecureContext* sc = Unwrap<SecureContext>(ctx.As<Object>());
CHECK_NOT_NULL(sc);
Expand All @@ -2511,14 +2507,13 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
return ThrowCryptoError(env, err, "CertCbDone");
}
} else {
} else if (ctx->IsObject()) {
// Failure: incorrect SNI context object
Local<Value> err = Exception::TypeError(env->sni_context_err_string());
w->MakeCallback(env->onerror_string(), 1, &err);
return;
}

fire_cb:
CertCb cb;
void* arg;

Expand Down

0 comments on commit ed01db6

Please sign in to comment.