From 5f35f5b4aca8eb879e374cfd9370ac7b0489cf94 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 5 May 2019 10:13:10 +0100 Subject: [PATCH] testsc.c: fix further memory leaks. These were spotted by Leak Sanitiser rather than Coverity: it reported them while I was checking the fixes for Coverity-spotted issues. --- testsc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/testsc.c b/testsc.c index 4e457617..2005a210 100644 --- a/testsc.c +++ b/testsc.c @@ -334,6 +334,7 @@ static void test_mp_get_nbits(void) log_end(); } mp_free(prev); + mp_free(z); } static void test_mp_from_decimal(void) @@ -386,6 +387,7 @@ static void test_mp_string_format(char *(*mp_format)(mp_int *x)) log_end(); sfree(formatted); } + mp_free(z); } static void test_mp_get_decimal(void) @@ -589,6 +591,10 @@ static void test_mp_modarith( mp_free(out); } + + mp_free(base); + mp_free(exponent); + mp_free(modulus); } static void test_mp_modadd(void) @@ -625,6 +631,8 @@ static void test_mp_invert_mod_2to(void) mp_free(out); } + + mp_free(x); } static void test_mp_modsqrt(void) @@ -647,7 +655,8 @@ static void test_mp_modsqrt(void) /* Do one initial call to cause the lazily initialised sub-context * to be set up. This will take a while, but it can't be helped. */ - mp_modsqrt(sc, x, &success); + mp_int *unwanted = mp_modsqrt(sc, x, &success); + mp_free(unwanted); for (size_t i = 0; i < looplimit(8); i++) { mp_random_bits_into(x, bits - 1); @@ -802,6 +811,7 @@ static void test_ecc_weierstrass_multiply(void) } ecc_weierstrass_point_free(a); ecc_weierstrass_curve_free(wc); + mp_free(exponent); } static void test_ecc_weierstrass_is_identity(void) @@ -1000,6 +1010,7 @@ static void test_ecc_montgomery_multiply(void) } ecc_montgomery_point_free(a); ecc_montgomery_curve_free(wc); + mp_free(exponent); } static void test_ecc_montgomery_get_affine(void) @@ -1132,6 +1143,7 @@ static void test_ecc_edwards_multiply(void) } ecc_edwards_point_free(a); ecc_edwards_curve_free(ec); + mp_free(exponent); } static void test_ecc_edwards_eq(void)