From fcbbb6b6eb594be079894681d23e318918f6bf26 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 11 Jun 2016 14:20:28 +0000 Subject: fix memroy leak --- src/util/crypto_kdf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/util/crypto_kdf.c b/src/util/crypto_kdf.c index c760ba33a..b62b5c847 100644 --- a/src/util/crypto_kdf.c +++ b/src/util/crypto_kdf.c @@ -108,7 +108,7 @@ GNUNET_CRYPTO_kdf (void *result, size_t out_len, void GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, gcry_mpi_t n, - const void *xts, size_t xts_len, + const void *xts, size_t xts_len, const void *skm, size_t skm_len, const char *ctx) { @@ -121,7 +121,8 @@ GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, /* GNUNET_assert (nbits > 512); */ ctr = 0; - do { + while (1) + { /* Ain't clear if n is always divisible by 8 */ uint8_t buf[ (nbits-1)/8 + 1 ]; @@ -145,7 +146,8 @@ GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, GNUNET_assert( 0 == gcry_mpi_test_bit (*r, nbits) ); ++ctr; /* We reject this FDH if either *r > n and retry with another ctr */ - } while ( 0 <= gcry_mpi_cmp(*r,n) ); + if (0 > gcry_mpi_cmp(*r, n)) + break; + gcry_mpi_release (*r); + } } - - -- cgit v1.2.3