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 <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
  • Loading branch information
shigeki authored and MylesBorins committed Jan 24, 2017
1 parent 8c7391b commit 705fac9
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 705fac9

Please sign in to comment.