Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
tls: preallocate SSL cipher array
  • Loading branch information
tniessen committed Aug 5, 2018
commit dbf583218054b49388335d9a98298d03f2a5acbb
5 changes: 3 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4849,10 +4849,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