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)
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 */