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 authored and targos committed Aug 11, 2018
1 parent d13d60d commit b1a9cf7
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 b1a9cf7

Please sign in to comment.