Fix a leak in evp_test
authorMatt Caswell <matt@openssl.org>
Fri, 28 Jun 2019 14:06:55 +0000 (15:06 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 1 Jul 2019 09:30:49 +0000 (10:30 +0100)
If evp_test fails to load the legacy provider then it leaks a reference
to the default provider.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9270)

test/evp_test.c

index 6fc9f03797a8fbfc2ea19e59204ce449e3478352..b70b4ea600c347e598fecd2b5d72c94ddd0412c5 100644 (file)
@@ -3096,8 +3096,10 @@ int setup_tests(void)
         return 0;
 #ifndef NO_LEGACY_MODULE
     legacyprov = OSSL_PROVIDER_load(NULL, "legacy");
-    if (!TEST_ptr(legacyprov))
+    if (!TEST_ptr(legacyprov)) {
+        OSSL_PROVIDER_unload(defltprov);
         return 0;
+    }
 #endif /* NO_LEGACY_MODULE */
 
     ADD_ALL_TESTS(run_file_tests, n);