test/evp_extra_test.c: Add check for BIO_new()

Add check for the return value of BIO_new() to avoid NULL pointer dereference.

Fixes: fd19fc4c27 ("Test that a key is usable after an EVP_PKEY_fromdata call")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27994)
This commit is contained in:
Jiasheng Jiang
2025-07-08 22:39:31 +00:00
committed by Neil Horman
parent 0755a8ef90
commit 7ed1f08326

View File

@@ -1185,6 +1185,9 @@ static int test_selection(EVP_PKEY *pkey, int selection)
int ret;
BIO *bio = BIO_new(BIO_s_mem());
if (!TEST_ptr(bio))
goto err;
ret = PEM_write_bio_PUBKEY(bio, pkey);
if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
if (!TEST_true(ret))