summaryrefslogtreecommitdiffstats
path: root/crypto/property
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2022-06-02 11:14:32 +0100
committerMatt Caswell <matt@openssl.org>2022-06-09 11:37:48 +0100
commit17703a0e65618795d01c67ddaf0bd28b08dd3955 (patch)
treeb79e2e2f58beddb19d3fc4176c107a93aa6313e3 /crypto/property
parent060f2bcae10617fcc85591718ee09228b50759de (diff)
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 <tomas@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18458) (cherry picked from commit fed8dbea27b7e01ee934951b25c6ffd40ad1d5c3)
Diffstat (limited to 'crypto/property')
-rw-r--r--crypto/property/property.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/property/property.c b/crypto/property/property.c
index 83f49d92d5..790abfd13b 100644
--- a/crypto/property/property.c
+++ b/crypto/property/property.c
@@ -312,7 +312,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);