From: Niels Dossche Date: Wed, 20 Nov 2024 18:57:38 +0000 (+0100) Subject: Fix potential memory leak on failure of ecx_gen_init() X-Git-Tag: openssl-3.1.8~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3aa4ef5469cd13ee6d9e412ceb12f42ebcdcd390;p=thirdparty%2Fopenssl.git Fix potential memory leak on failure of ecx_gen_init() When ecx_gen_set_params() returns 0, it could have duplicated the memory for the parameter OSSL_KDF_PARAM_PROPERTIES already in gctx->propq, leading to a memory leak. Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/26015) (cherry picked from commit 98be2e8fb60aaece2e4c3d42e87671fe22c081a2) --- diff --git a/providers/implementations/keymgmt/ecx_kmgmt.c b/providers/implementations/keymgmt/ecx_kmgmt.c index 987d38456fb..94e62f755c2 100644 --- a/providers/implementations/keymgmt/ecx_kmgmt.c +++ b/providers/implementations/keymgmt/ecx_kmgmt.c @@ -487,7 +487,7 @@ static void *ecx_gen_init(void *provctx, int selection, gctx->selection = selection; } if (!ecx_gen_set_params(gctx, params)) { - OPENSSL_free(gctx); + ecx_gen_cleanup(gctx); gctx = NULL; } return gctx;