test/provider_fallback_test.c: Add OSSL_PROVIDER_unload() to avoid memory leak

Add OSSL_PROVIDER_unload() when test_provider() fails to avoid memory leak.

Fixes: f995e5bdcd ("TEST: Add provider_fallback_test, to test aspects of
fallback providers")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@outlook.com>

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25108)
This commit is contained in:
Jiasheng Jiang 2024-08-06 18:42:06 +00:00 committed by Tomas Mraz
parent 60358f2c5e
commit 6e8a1031ed

View File

@ -39,9 +39,15 @@ static int test_explicit_provider(void)
int ok;
ok = TEST_ptr(ctx = OSSL_LIB_CTX_new())
&& TEST_ptr(prov = OSSL_PROVIDER_load(ctx, "default"))
&& test_provider(ctx)
&& TEST_true(OSSL_PROVIDER_unload(prov));
&& TEST_ptr(prov = OSSL_PROVIDER_load(ctx, "default"));
if (ok) {
ok = test_provider(ctx);
if (ok)
ok = TEST_true(OSSL_PROVIDER_unload(prov));
else
OSSL_PROVIDER_unload(prov);
}
OSSL_LIB_CTX_free(ctx);
return ok;