Skip to content

Commit 705fac9

Browse files
shigekiMylesBorins
authored andcommitted
crypto: remove unnecessary variables of alpn/npn
The Local variables of `npn_buffer` and `alpn_buffer` are not necessary to be created from `args[0]`. Remove and fold them into the subsequent call. PR-URL: #10831 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent 8c7391b commit 705fac9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/node_crypto.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,8 +2073,8 @@ void SSLWrap<Base>::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
20732073
if (args.Length() < 1 || !Buffer::HasInstance(args[0]))
20742074
return env->ThrowTypeError("Must give a Buffer as first argument");
20752075

2076-
Local<Value> npn_buffer = Local<Value>::New(env->isolate(), args[0]);
2077-
bool r = w->object()->SetHiddenValue(env->npn_buffer_string(), npn_buffer);
2076+
bool r = w->object()->SetHiddenValue(env->npn_buffer_string(), args[0]);
2077+
20782078
CHECK(r);
20792079
}
20802080
#endif // OPENSSL_NPN_NEGOTIATED
@@ -2156,9 +2156,8 @@ void SSLWrap<Base>::SetALPNProtocols(
21562156
int r = SSL_set_alpn_protos(w->ssl_, alpn_protos, alpn_protos_len);
21572157
CHECK_EQ(r, 0);
21582158
} else {
2159-
Local<Value> alpn_buffer = Local<Value>::New(env->isolate(), args[0]);
2160-
bool ret = w->object()->SetHiddenValue(env->alpn_buffer_string(),
2161-
alpn_buffer);
2159+
bool ret = w->object()->SetHiddenValue(env->alpn_buffer_string(), args[0]);
2160+
21622161
CHECK(ret);
21632162
// Server should select ALPN protocol from list of advertised by client
21642163
SSL_CTX_set_alpn_select_cb(w->ssl_->ctx, SelectALPNCallback, nullptr);

0 commit comments

Comments
 (0)