Skip to content

Commit

Permalink
crypto: remove unnecessary variables of alpn/npn
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
shigeki authored and MylesBorins committed Feb 1, 2017
1 parent a67ada7 commit 4cf7dcf
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2073,8 +2073,8 @@ void SSLWrap<Base>::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
if (args.Length() < 1 || !Buffer::HasInstance(args[0]))
return env->ThrowTypeError("Must give a Buffer as first argument");

Local<Value> npn_buffer = Local<Value>::New(env->isolate(), args[0]);
bool r = w->object()->SetHiddenValue(env->npn_buffer_string(), npn_buffer);
bool r = w->object()->SetHiddenValue(env->npn_buffer_string(), args[0]);

CHECK(r);
}
#endif // OPENSSL_NPN_NEGOTIATED
Expand Down Expand Up @@ -2156,9 +2156,8 @@ void SSLWrap<Base>::SetALPNProtocols(
int r = SSL_set_alpn_protos(w->ssl_, alpn_protos, alpn_protos_len);
CHECK_EQ(r, 0);
} else {
Local<Value> alpn_buffer = Local<Value>::New(env->isolate(), args[0]);
bool ret = w->object()->SetHiddenValue(env->alpn_buffer_string(),
alpn_buffer);
bool ret = w->object()->SetHiddenValue(env->alpn_buffer_string(), args[0]);

CHECK(ret);
// Server should select ALPN protocol from list of advertised by client
SSL_CTX_set_alpn_select_cb(w->ssl_->ctx, SelectALPNCallback, nullptr);
Expand Down

0 comments on commit 4cf7dcf

Please sign in to comment.