summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiasheng Jiang <jiashengjiangcool@outlook.com>2024-08-06 20:42:06 +0200
committerTomas Mraz <tomas@openssl.org>2024-08-21 15:37:05 +0200
commit6e8a1031ed11af9645769f9e019db9f032a220b8 (patch)
treedccb0402759c92a545c935b9d11a549f9ba3d1c6
parentFix the alert used on a missing key_share (diff)
downloadopenssl-6e8a1031ed11af9645769f9e019db9f032a220b8.tar.xz
openssl-6e8a1031ed11af9645769f9e019db9f032a220b8.zip
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)
-rw-r--r--test/provider_fallback_test.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/test/provider_fallback_test.c b/test/provider_fallback_test.c
index 5902f57c85..f5c1ec52c6 100644
--- a/test/provider_fallback_test.c
+++ b/test/provider_fallback_test.c
@@ -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;