]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
lib/accelerated/x86/hmac-padlock.c: Add gnutls_free() to avoid memory leak
authorJiasheng Jiang <jian1000@purdue.edu>
Mon, 16 Jun 2025 05:24:14 +0000 (05:24 +0000)
committerDaiki Ueno <ueno@gnu.org>
Mon, 16 Jun 2025 05:24:14 +0000 (14:24 +0900)
Add gnutls_free() to free ctx if _hmac_ctx_init() fails to avoid memory leak.

Fixes: 38a089b67 ("Updates for padlock hashes in C7 nano. Requires a part of nettle to be included.")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
lib/accelerated/x86/hmac-padlock.c

index 18003c1607d8652efb30e5c60f50c2ed594c5437..26847e8b4e064af1ed5044e1b1d43e0109ebe7a0 100644 (file)
@@ -201,8 +201,10 @@ static int wrap_padlock_hmac_init(gnutls_mac_algorithm_t algo, void **_ctx)
        ctx->algo = algo;
 
        ret = _hmac_ctx_init(algo, ctx);
-       if (ret < 0)
+       if (ret < 0) {
+               gnutls_free(ctx);
                return gnutls_assert_val(ret);
+       }
 
        *_ctx = ctx;