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 <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
tniessen committed Aug 9, 2018
1 parent 8e1b6e7 commit 4253e55
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 @@ -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,
Expand Down

0 comments on commit 4253e55

Please sign in to comment.