]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/bio_pw_callback_test.c: Add BIO_free() to avoid memory leak
authorJiasheng Jiang <jiashengjiangcool@gmail.com>
Wed, 25 Jun 2025 19:22:30 +0000 (19:22 +0000)
committerTomas Mraz <tomas@openssl.org>
Tue, 1 Jul 2025 18:33:28 +0000 (20:33 +0200)
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 <jiashengjiangcool@gmail.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27898)

test/bio_pw_callback_test.c

index e11368454a8c9f2b78108a34b97df985af77a911..efdb333cff598b7af1bbd46b957b0f886ade423b 100644 (file)
@@ -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 */