From: Bartel Artem Date: Wed, 11 Jun 2025 03:58:31 +0000 (+0300) Subject: return NULL if gctx allocation fails. X-Git-Tag: openssl-3.4.2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=343579a29b17c3de8b8132748d63be4819e452bb;p=thirdparty%2Fopenssl.git 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) --- diff --git a/providers/implementations/keymgmt/ecx_kmgmt.c b/providers/implementations/keymgmt/ecx_kmgmt.c index 219071d6491..f2e7c795fc1 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; }