From dd4b248e9bf98f207669982e876500bd1981a604 Mon Sep 17 00:00:00 2001 From: Don Isaac Date: Mon, 30 Dec 2024 21:10:21 -0500 Subject: [PATCH] fix(us): memory leak when getting root certificate --- packages/bun-usockets/src/crypto/root_certs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/bun-usockets/src/crypto/root_certs.cpp b/packages/bun-usockets/src/crypto/root_certs.cpp index f675a0ab16e80e..0e8c8541d9a8a3 100644 --- a/packages/bun-usockets/src/crypto/root_certs.cpp +++ b/packages/bun-usockets/src/crypto/root_certs.cpp @@ -35,6 +35,9 @@ us_ssl_ctx_get_X509_without_callback_from(struct us_cert_string_t content) { OPENSSL_PUT_ERROR(SSL, ERR_R_PEM_LIB); goto end; } + + // NOTE: PEM_read_bio_X509 allocates, so input BIO must be freed. + BIO_free(in); return x; end: X509_free(x); @@ -140,4 +143,4 @@ extern "C" X509_STORE *us_get_default_ca_store() { } return store; -} \ No newline at end of file +}