From: Matt Caswell Date: Thu, 2 Jun 2022 10:14:32 +0000 (+0100) Subject: Fix a memory leak in ossl_method_store_add() X-Git-Tag: openssl-3.2.0-alpha1~2553 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fed8dbea27b7e01ee934951b25c6ffd40ad1d5c3;p=thirdparty%2Fopenssl.git Fix a memory leak in ossl_method_store_add() If the call to ossl_prop_defn_set() fails then the OSSL_PROPERTY_LIST we just created will leak. Found as a result of: https://github.com/openssl/openssl/pull/18355#issuecomment-1139499881 Reviewed-by: Tomas Mraz Reviewed-by: Todd Short Reviewed-by: Hugo Landau Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/18458) --- diff --git a/crypto/property/property.c b/crypto/property/property.c index d209f2c79db..fb48022a8f0 100644 --- a/crypto/property/property.c +++ b/crypto/property/property.c @@ -304,7 +304,11 @@ int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov, impl->properties = ossl_parse_property(store->ctx, properties); if (impl->properties == NULL) goto err; - ossl_prop_defn_set(store->ctx, properties, impl->properties); + if (!ossl_prop_defn_set(store->ctx, properties, impl->properties)) { + ossl_property_free(impl->properties); + impl->properties = NULL; + goto err; + } } alg = ossl_method_store_retrieve(store, nid);