From: Nikos Mavrogiannopoulos Date: Tue, 10 Jan 2012 17:22:18 +0000 (+0100) Subject: Eliminated memory leak in ecc_projective_check_point(). X-Git-Tag: gnutls-3_0_12~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ae59e39662f934f2e697a2b546cdda4cfe4eb9b6;p=thirdparty%2Fgnutls.git Eliminated memory leak in ecc_projective_check_point(). --- diff --git a/NEWS b/NEWS index da74964ca3..0212a99631 100644 --- a/NEWS +++ b/NEWS @@ -7,8 +7,8 @@ See the end for copying conditions. ** certtool: --outder option now works for private and public keys as well. -** libgnutls: Corrected memory leak in DH parameter -generation. +** libgnutls: Corrected memory leaks in DH parameter +generation and ecc_projective_check_point(). ** libgnutls: Added gnutls_x509_dn_oid_name() to return a descriptive name of a DN OID. diff --git a/lib/nettle/ecc_projective_check_point.c b/lib/nettle/ecc_projective_check_point.c index 42abeea18b..564977964b 100644 --- a/lib/nettle/ecc_projective_check_point.c +++ b/lib/nettle/ecc_projective_check_point.c @@ -42,17 +42,17 @@ int ecc_projective_check_point (ecc_point * P, mpz_t b, mpz_t modulus) if (P == NULL || b == NULL || modulus == NULL) return -1; - if ((err = mp_init_multi (&t1, &t2, &t3, NULL)) != 0) - { - return err; - } - if (mpz_cmp_ui (P->z, 1) != 0) { gnutls_assert (); return -1; } + if ((err = mp_init_multi (&t1, &t2, &t3, NULL)) != 0) + { + return err; + } + /* t1 = Z * Z */ mpz_mul (t1, P->y, P->y); mpz_mod (t1, t1, modulus); /* t1 = y^2 */ @@ -95,12 +95,16 @@ int ecc_projective_check_point (ecc_point * P, mpz_t b, mpz_t modulus) if (mpz_cmp_ui (t1, 0) != 0) { - return -1; + err = -1; } else { - return 0; + err = 0; } + + mp_clear_multi(&t1, &t2, &t3, NULL); + + return err; } #endif