diff options
author | Tobias Nießen <tniessen@tnie.de> | 2018-08-05 13:17:35 +0300 |
---|---|---|
committer | Tobias Nießen <tniessen@tnie.de> | 2018-08-09 17:07:50 +0300 |
commit | 4253e5583bf4b50ef0b3b2776581d8ca8d8bcd1d (patch) | |
tree | 9a22d0d1eec1fa4c0699d2b0885d7b5d7b058e30 /src | |
parent | 8e1b6e771867fc4e89715cf22501dfe2f01cf8d0 (diff) |
tls: preallocate SSL cipher array
PR-URL: https://github.com/nodejs/node/pull/22136
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_crypto.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 0ee7156715c..51c2fe2648c 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4850,10 +4850,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, |