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 <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18413)
This commit is contained in:
Matt Caswell 2022-05-26 15:34:38 +01:00
parent da31939763
commit b4be10dfcd
1 changed files with 3 additions and 1 deletions

View 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;