From 3e6ef835b16ace701c7d110e1ecd34dbf8689a38 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Fri, 17 Feb 2017 12:06:27 -0800 Subject: [PATCH] Free the ecc keys --- wolfcrypt/test/test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 216b317b2..fb560b6fe 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -8214,8 +8214,14 @@ static int ecc_test_cdh_vectors(void) const char* ZIUT = "46fc62106420ff012e54a434fbdd2d25ccc5852060561e68040dd7778997bd7b"; /* setup private and public keys */ - wc_ecc_init(&pub_key); - wc_ecc_init(&priv_key); + ret = wc_ecc_init(&pub_key); + if (ret != 0) + return ret; + ret = wc_ecc_init(&priv_key); + if (ret != 0) { + wc_ecc_free(&pub_key); + goto done; + } wc_ecc_set_flags(&pub_key, WC_ECC_FLAG_COFACTOR); wc_ecc_set_flags(&priv_key, WC_ECC_FLAG_COFACTOR); ret = wc_ecc_import_raw(&pub_key, QCAVSx, QCAVSy, NULL, "SECP256R1"); @@ -8244,6 +8250,8 @@ static int ecc_test_cdh_vectors(void) } done: + wc_ecc_free(&priv_key); + wc_ecc_free(&pub_key); return ret; } #endif /* HAVE_ECC_CDH */