Skip to content

Commit 007b4c1

Browse files
tniessenaddaleax
authored andcommitted
src: refactor CertCbDone to avoid goto statement
PR-URL: #34325 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 88bd124 commit 007b4c1

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/node_crypto.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,10 +2474,6 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
24742474
env->sni_context_string()).ToLocalChecked();
24752475
Local<FunctionTemplate> cons = env->secure_context_constructor_template();
24762476

2477-
// Not an object, probably undefined or null
2478-
if (!ctx->IsObject())
2479-
goto fire_cb;
2480-
24812477
if (cons->HasInstance(ctx)) {
24822478
SecureContext* sc = Unwrap<SecureContext>(ctx.As<Object>());
24832479
CHECK_NOT_NULL(sc);
@@ -2490,14 +2486,13 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
24902486
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
24912487
return ThrowCryptoError(env, err, "CertCbDone");
24922488
}
2493-
} else {
2489+
} else if (ctx->IsObject()) {
24942490
// Failure: incorrect SNI context object
24952491
Local<Value> err = Exception::TypeError(env->sni_context_err_string());
24962492
w->MakeCallback(env->onerror_string(), 1, &err);
24972493
return;
24982494
}
24992495

2500-
fire_cb:
25012496
CertCb cb;
25022497
void* arg;
25032498

0 commit comments

Comments
 (0)