Skip to content

Commit

Permalink
tls: preallocate SSL cipher array
Browse files Browse the repository at this point in the history
PR-URL: #22136
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
tniessen authored and rvagg committed Aug 15, 2018
1 parent 8b5485d commit f989681
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4835,10 +4835,11 @@ void GetSSLCiphers(const FunctionCallbackInfo<Value>& args) {
SSLPointer ssl(SSL_new(ctx.get()));
CHECK(ssl);

Local<Array> arr = Array::New(env->isolate());
STACK_OF(SSL_CIPHER)* ciphers = SSL_get_ciphers(ssl.get());
int n = sk_SSL_CIPHER_num(ciphers);
Local<Array> arr = Array::New(env->isolate(), n);

for (int i = 0; i < sk_SSL_CIPHER_num(ciphers); ++i) {
for (int i = 0; i < n; ++i) {
const SSL_CIPHER* cipher = sk_SSL_CIPHER_value(ciphers, i);
arr->Set(env->context(),
i,
Expand Down

0 comments on commit f989681

Please sign in to comment.