From: Matt Caswell Date: Thu, 26 May 2022 14:34:38 +0000 (+0100) Subject: Fix a memory leak is ossl_provider_doall_activated X-Git-Tag: openssl-3.2.0-alpha1~2585 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4be10dfcd370960cecfda9773e1bfcc568a7390;p=thirdparty%2Fopenssl.git Fix a memory leak is ossl_provider_doall_activated 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 Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/18413) --- diff --git a/crypto/provider_core.c b/crypto/provider_core.c index 3e2738fb32a..53f04400a09 100644 --- a/crypto/provider_core.c +++ b/crypto/provider_core.c @@ -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;