]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
mac_legacy_kmgmt.c: Avoid possible memory leak on error
authorTomas Mraz <tomas@openssl.org>
Tue, 21 Jan 2025 13:38:23 +0000 (14:38 +0100)
committerTomas Mraz <tomas@openssl.org>
Thu, 23 Jan 2025 11:12:32 +0000 (12:12 +0100)
Use mac_gen_cleanup() instead of just freeing the gctx.
Fixes Coverity 1638702

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/26500)

(cherry picked from commit 2455ef2112997d6a366623a209f1d0090ed2d847)

providers/implementations/keymgmt/mac_legacy_kmgmt.c

index 1fae4407fca6093a63e14ea17fa7200449e35458..6e4ca49529bec1a4251992535f7da35f9c5b197c 100644 (file)
@@ -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;