From 7bd3cccd8750d50676f07476118e560e0282817f Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Tue, 16 Feb 2021 17:47:00 +0100 Subject: [PATCH] Fix memory leak in fp_gcd ZD 11732 --- wolfcrypt/src/tfm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index aefcdcfe3..509026326 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -5279,6 +5279,9 @@ int fp_gcd(fp_int *a, fp_int *b, fp_int *c) while (fp_iszero(v) == FP_NO) { int err = fp_mod(u, v, r); if (err != MP_OKAY) { +#ifdef WOLFSSL_SMALL_STACK + XFREE(u, NULL, DYNAMIC_TYPE_BIGINT); +#endif return err; } fp_copy(v, u);