From: Tomas Mraz Date: Mon, 23 Jun 2025 12:41:38 +0000 (+0200) Subject: evp_extra_test2.c: Fix doublefree of PKEY and leak of RSA X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=53a83a7921763aa6637e875aec55f504aa5f5df2;p=thirdparty%2Fopenssl.git evp_extra_test2.c: Fix doublefree of PKEY and leak of RSA Fixes Coverity 1649567 Reviewed-by: Shane Lontis Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/27880) --- diff --git a/test/evp_extra_test2.c b/test/evp_extra_test2.c index 90690bbeb52..34cceb5ebfc 100644 --- a/test/evp_extra_test2.c +++ b/test/evp_extra_test2.c @@ -1271,14 +1271,15 @@ static int test_pkey_export(void) /* Now, try with a legacy key */ pdata = keydata[0].kder; pdata_len = keydata[0].size; - if (!TEST_ptr(rsa = d2i_RSAPrivateKey(NULL, &pdata, pdata_len)) - || !TEST_ptr(pkey = EVP_PKEY_new()) - || !TEST_true(EVP_PKEY_assign_RSA(pkey, rsa)) + if (!TEST_ptr(pkey = EVP_PKEY_new()) + || !TEST_ptr(rsa = d2i_RSAPrivateKey(NULL, &pdata, pdata_len)) + || !TEST_true(EVP_PKEY_set1_RSA(pkey, rsa)) || !TEST_true(EVP_PKEY_export(pkey, EVP_PKEY_KEYPAIR, test_pkey_export_cb, pkey)) || !TEST_false(EVP_PKEY_export(pkey, EVP_PKEY_KEYPAIR, test_pkey_export_cb, NULL))) ret = 0; + RSA_free(rsa); EVP_PKEY_free(pkey); #endif return ret;