]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Eliminated memory leak in ecc_projective_check_point().
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Tue, 10 Jan 2012 17:22:18 +0000 (18:22 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Tue, 10 Jan 2012 17:22:38 +0000 (18:22 +0100)
NEWS
lib/nettle/ecc_projective_check_point.c

diff --git a/NEWS b/NEWS
index da74964ca33ee9307b93940b87029d2360fdb60b..0212a996316d1e629928745c84f79f26d5938dd6 100644 (file)
--- 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.
index 42abeea18bafd28ec57348d43142eb70f7342bda..564977964bfc90072905712942efccdebf42d4dd 100644 (file)
@@ -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