Commit 478c2eea871 for nodejs

commit 478c2eea871d09554530ddf298d2bb2fceab077c
Author: Tim Perry <pimterry@gmail.com>
Date:   Wed Nov 25 17:52:56 2026 +0100

    tls: fix OpenSSL compression leak that breaks tests under ASAN

    This is not impactful in any way - it's a fixed leak of the openssl
    record compression descriptors, about 24 bytes leaked total, once
    per process. Not meaningful.

    It is annoying if you want to run with ASAN & leak detection though,
    since it's an unambiguous leak we trigger every time crypto is used.

    Signed-off-by: Tim Perry <pimterry@gmail.com>
    PR-URL: https://github.com/nodejs/node/pull/66600
    Reviewed-By: Filip Skokan <panva.ip@gmail.com>

diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc
index b8aa47adda4..fe148c0a2c5 100644
--- a/src/crypto/crypto_util.cc
+++ b/src/crypto/crypto_util.cc
@@ -526,7 +526,10 @@ void InitCryptoOnce() {

   // Turn off compression. Saves memory and protects against CRIME attacks.
   // No-op with OPENSSL_NO_COMP builds of OpenSSL.
-  sk_SSL_COMP_zero(SSL_COMP_get_compression_methods());
+  STACK_OF(SSL_COMP)* comp_methods = SSL_COMP_get_compression_methods();
+  while (sk_SSL_COMP_num(comp_methods) > 0) {
+    OPENSSL_free(sk_SSL_COMP_pop(comp_methods));
+  }
 }

 void GetFipsCrypto(const FunctionCallbackInfo<Value>& args) {
diff --git a/test/parallel/test-tls-certificate-compression.js b/test/parallel/test-tls-certificate-compression.js
index b543ae4143c..5dc4190c8fa 100644
--- a/test/parallel/test-tls-certificate-compression.js
+++ b/test/parallel/test-tls-certificate-compression.js
@@ -76,8 +76,8 @@ const fixtureCert = fixtures.readKey('agent1-cert.pem');
 // Test: certificate compression must not enable record-level compression.
 //
 // RFC 8879 certificate compression is unrelated to TLS record compression
-// (the CRIME attack vector). The latter is disabled by Node at startup via
-// sk_SSL_COMP_zero, and by modern OpenSSL defaults as well. To confirm, we
+// (the CRIME attack vector). The latter is disabled by Node at startup in
+// InitCryptoOnce(), and by modern OpenSSL defaults as well. To confirm, we
 // Verify a ClientHello sent by Node only advertises null record compression.
 (async () => {
   const { promise: clientHelloReceived, resolve: onClientHello } =