From: Niels Dossche Date: Mon, 8 Dec 2025 14:17:56 +0000 (+0100) Subject: Fix memory leak in error path of ec_gen_init() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b6d759886e84f598f8e2142a6609085f77feebb;p=thirdparty%2Fopenssl.git Fix memory leak in error path of ec_gen_init() ec_gen_set_params() can fail after some big numbers have already been copied over. Those need to be cleaned to avoid a memory leak on failure. This can be done with ec_gen_cleanup(), which is also consistent in how the ecx_gen code does it. Reviewed-by: Dmitry Belyavskiy Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/29335) (cherry picked from commit 26d138af724961c5f30263c15ae8137d4f86645b) --- diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c index f9da63d17d7..63027cb569e 100644 --- a/providers/implementations/keymgmt/ec_kmgmt.c +++ b/providers/implementations/keymgmt/ec_kmgmt.c @@ -974,7 +974,7 @@ static void *ec_gen_init(void *provctx, int selection, gctx->selection = selection; gctx->ecdh_mode = 0; if (!ec_gen_set_params(gctx, params)) { - OPENSSL_free(gctx); + ec_gen_cleanup(gctx); gctx = NULL; } }