]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix a memory leak is ossl_provider_doall_activated
authorMatt Caswell <matt@openssl.org>
Thu, 26 May 2022 14:34:38 +0000 (15:34 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 2 Jun 2022 09:31:12 +0000 (10:31 +0100)
If the callback fails then we don't correctly free providers that were
already in our stack and that we up-refed earlier.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18413)

crypto/provider_core.c

index 3e2738fb32a4aad15e8ee63d4fb62c158a2c08cc..53f04400a09aa43946d65e374c3c728841e2e44e 100644 (file)
@@ -1401,8 +1401,10 @@ int ossl_provider_doall_activated(OSSL_LIB_CTX *ctx,
     for (curr = 0; curr < max; curr++) {
         OSSL_PROVIDER *prov = sk_OSSL_PROVIDER_value(provs, curr);
 
-        if (!cb(prov, cbdata))
+        if (!cb(prov, cbdata)) {
+            curr = -1;
             goto finish;
+        }
     }
     curr = -1;