From 2ad09ef41396c22ade94a2cd3257843f0439b044 Mon Sep 17 00:00:00 2001 From: Jiasheng Jiang Date: Wed, 25 Jun 2025 19:22:30 +0000 Subject: [PATCH] test/bio_pw_callback_test.c: Add BIO_free() to avoid memory leak Add BIO_free() if PEM_read_bio_PrivateKey fails to avoid memory leak. Fixes: fa6ae88a47 ("Add test for BIO password callback functionality") Signed-off-by: Jiasheng Jiang Reviewed-by: Paul Dale Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/27898) --- test/bio_pw_callback_test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/bio_pw_callback_test.c b/test/bio_pw_callback_test.c index e11368454a8..efdb333cff5 100644 --- a/test/bio_pw_callback_test.c +++ b/test/bio_pw_callback_test.c @@ -372,8 +372,10 @@ int setup_tests(void) if (!TEST_ptr(bio = BIO_new_file(key_file, "r"))) return 0; if (!TEST_ptr(PEM_read_bio_PrivateKey(bio, &original_pkey, - callback_original_pw, NULL))) + callback_original_pw, NULL))) { + BIO_free(bio); return 0; + } BIO_free(bio); /* add all tests */ -- 2.47.3