From 09bae9da3ef6e414d7efd6d86c87940a18061c48 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Fri, 17 Feb 2017 11:18:05 -0800 Subject: [PATCH] Fixup from review --- wolfcrypt/src/ecc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 51d310a7a..8d861fa6c 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -2585,7 +2585,7 @@ static int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point* point, /* if cofactor flag has been set */ if (private_key->flags & WC_ECC_FLAG_COFACTOR) { - int cofactor = private_key->dp->cofactor; + mp_digit cofactor = (mp_digit)private_key->dp->cofactor; /* only perform cofactor calc if not equal to 1 */ if (cofactor != 1) { k = &k_lcl; @@ -2604,7 +2604,10 @@ static int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point* point, /* make new point */ result = wc_ecc_new_point_h(private_key->heap); if (result == NULL) { - mp_clear(k); +#ifdef HAVE_ECC_CDH + if (k == &k_lcl) + mp_clear(k); +#endif return MEMORY_E; }