Skip to content

Commit f989681

Browse files
tniessenrvagg
authored andcommitted
tls: preallocate SSL cipher array
PR-URL: #22136 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 8b5485d commit f989681

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/node_crypto.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -4835,10 +4835,11 @@ void GetSSLCiphers(const FunctionCallbackInfo<Value>& args) {
48354835
SSLPointer ssl(SSL_new(ctx.get()));
48364836
CHECK(ssl);
48374837

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

4841-
for (int i = 0; i < sk_SSL_CIPHER_num(ciphers); ++i) {
4842+
for (int i = 0; i < n; ++i) {
48424843
const SSL_CIPHER* cipher = sk_SSL_CIPHER_value(ciphers, i);
48434844
arr->Set(env->context(),
48444845
i,

0 commit comments

Comments
 (0)