From 026b0d3e1e7667ccc5a9d67bd9bd99a404563369 Mon Sep 17 00:00:00 2001 From: shridhar kalavagunta Date: Thu, 11 Apr 2024 20:42:37 -0500 Subject: Fix memory leak on error in crypto/conf/conf_mod.c Fixes #24111 Reviewed-by: Tom Cosgrove Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/24119) (cherry picked from commit 5bbdbce856c7ca132e039a24a315618484874c81) --- crypto/conf/conf_mod.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c index a19575af37..ca87315012 100644 --- a/crypto/conf/conf_mod.c +++ b/crypto/conf/conf_mod.c @@ -518,13 +518,14 @@ void CONF_modules_unload(int all) old_modules = ossl_rcu_deref(&supported_modules); new_modules = sk_CONF_MODULE_dup(old_modules); - to_delete = sk_CONF_MODULE_new_null(); if (new_modules == NULL) { ossl_rcu_write_unlock(module_list_lock); return; } + to_delete = sk_CONF_MODULE_new_null(); + /* unload modules in reverse order */ for (i = sk_CONF_MODULE_num(new_modules) - 1; i >= 0; i--) { md = sk_CONF_MODULE_value(new_modules, i); -- cgit v1.2.3