From b4be10dfcd370960cecfda9773e1bfcc568a7390 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Thu, 26 May 2022 15:34:38 +0100 Subject: [PATCH] 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) --- crypto/provider_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- 2.47.2