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.4.1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e949bf946b598c90fbc1ff2f53d5f43323f4663;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 f952ebb2277..0bb187c105d 100644 --- a/providers/implementations/keymgmt/mac_legacy_kmgmt.c +++ b/providers/implementations/keymgmt/mac_legacy_kmgmt.c @@ -393,7 +393,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; @@ -405,7 +405,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;