From: Tomas Mraz Date: Tue, 21 Jan 2025 13:38:23 +0000 (+0100) Subject: mac_legacy_kmgmt.c: Avoid possible memory leak on error X-Git-Tag: openssl-3.1.8~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f71858d4a4687875da030b5e1a9e58fd0cb246be;p=thirdparty%2Fopenssl.git mac_legacy_kmgmt.c: Avoid possible memory leak on error Use mac_gen_cleanup() instead of just freeing the gctx. Fixes Coverity 1638702 Reviewed-by: Neil Horman Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/26500) (cherry picked from commit 2455ef2112997d6a366623a209f1d0090ed2d847) --- diff --git a/providers/implementations/keymgmt/mac_legacy_kmgmt.c b/providers/implementations/keymgmt/mac_legacy_kmgmt.c index ba3a46324f2..8648f9a9c7f 100644 --- a/providers/implementations/keymgmt/mac_legacy_kmgmt.c +++ b/providers/implementations/keymgmt/mac_legacy_kmgmt.c @@ -399,7 +399,7 @@ static void *mac_gen_init(void *provctx, int selection, struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection); if (gctx != NULL && !mac_gen_set_params(gctx, params)) { - OPENSSL_free(gctx); + mac_gen_cleanup(gctx); gctx = NULL; } return gctx; @@ -411,7 +411,7 @@ static void *cmac_gen_init(void *provctx, int selection, struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection); if (gctx != NULL && !cmac_gen_set_params(gctx, params)) { - OPENSSL_free(gctx); + mac_gen_cleanup(gctx); gctx = NULL; } return gctx;