From 89e6b1eebc162fd9c62cc3a88f548c7c37067440 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 26 Nov 2020 01:48:04 -0600 Subject: [PATCH] wc_ecc_mulmod_ex(): be more careful freeing temp key. --- wolfcrypt/src/ecc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index c66b4ceb3..c1faba239 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -3007,8 +3007,10 @@ exit: } #ifdef WOLFSSL_SMALL_STACK_CACHE if (key) { - R->key = NULL; - ecc_key_tmp_final(key, heap); + if (R) + R->key = NULL; + if (err == MP_OKAY) + ecc_key_tmp_final(key, heap); XFREE(key, heap, DYNAMIC_TYPE_ECC); } #endif /* WOLFSSL_SMALL_STACK_CACHE */