From: Jiasheng Jiang Date: Wed, 25 Jun 2025 19:22:30 +0000 (+0000) Subject: test/bio_pw_callback_test.c: Add BIO_free() to avoid memory leak X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2ad09ef41396c22ade94a2cd3257843f0439b044;p=thirdparty%2Fopenssl.git 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) --- 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 */