From 8d6a834da743b10b02d6d8ce26a58b018b314787 Mon Sep 17 00:00:00 2001 From: Bartel Artem Date: Wed, 11 Jun 2025 06:58:31 +0300 Subject: [PATCH] return NULL if gctx allocation fails. Reviewed-by: Tomas Mraz Reviewed-by: Paul Yang Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/27795) (cherry picked from commit 443298e0f0e2c8225f8c6d6fdc01c6c4d434028b) --- providers/implementations/keymgmt/ecx_kmgmt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/providers/implementations/keymgmt/ecx_kmgmt.c b/providers/implementations/keymgmt/ecx_kmgmt.c index 941dbfa35d8..c2ac805ad1f 100644 --- a/providers/implementations/keymgmt/ecx_kmgmt.c +++ b/providers/implementations/keymgmt/ecx_kmgmt.c @@ -505,15 +505,15 @@ static void *ecx_gen_init(void *provctx, int selection, if (algdesc != NULL && !ossl_FIPS_IND_callback(libctx, algdesc, "KeyGen Init")) { OPENSSL_free(gctx); - return 0; + return NULL; } #endif + } else { + return NULL; } if (!ecx_gen_set_params(gctx, params)) { - if (gctx != NULL) { - ecx_gen_cleanup(gctx); - gctx = NULL; - } + ecx_gen_cleanup(gctx); + gctx = NULL; } return gctx; } -- 2.47.2