From e852c090c0308b0fd9bc065579faf494e6c4ab03 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Sun, 15 Jun 2025 07:56:25 -0500 Subject: [PATCH] wolfssl/wolfcrypt/integer.h: for heapmath FREE_MP_INT_SIZE(), rather than WC_DO_NOTHING(), conditionally mp_free(), for functional isomorphism with sp_int and tfm MPI lifecycles. --- wolfssl/wolfcrypt/integer.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wolfssl/wolfcrypt/integer.h b/wolfssl/wolfcrypt/integer.h index 68bda1fcd..09cec4434 100644 --- a/wolfssl/wolfcrypt/integer.h +++ b/wolfssl/wolfcrypt/integer.h @@ -205,7 +205,12 @@ typedef int mp_err; #define NEW_MP_INT_SIZE(name, bits, heap, type) \ XMEMSET(name, 0, sizeof(mp_int)) /* Dispose of static mp_int. */ -#define FREE_MP_INT_SIZE(name, heap, type) WC_DO_NOTHING +#define FREE_MP_INT_SIZE(name, heap, type) \ + do { \ + if ((name) != NULL) { \ + mp_free(name); \ + } \ + } while (0) /* Initialize an mp_int. */ #define INIT_MP_INT_SIZE(name, bits) \ mp_init(name)