[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/6] pki_gcrypt: Fix memory leak
[Thread Prev] | [Thread Next]
- Subject: [PATCH 5/6] pki_gcrypt: Fix memory leak
- From: Justus Winter <justus@xxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Mon, 14 Mar 2016 16:32:01 +0100
- To: libssh@xxxxxxxxxx
- Cc: Justus Winter <justus@xxxxxxxxxxx>
* src/pki_gcrypt.c (_bignum_cmp): Fix memory leak. Signed-off-by: Justus Winter <justus@xxxxxxxxxxx> --- src/pki_gcrypt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pki_gcrypt.c b/src/pki_gcrypt.c index bc6a33e..70c6d28 100644 --- a/src/pki_gcrypt.c +++ b/src/pki_gcrypt.c @@ -1064,6 +1064,7 @@ static int _bignum_cmp(const gcry_sexp_t s1, gcry_sexp_t sexp; bignum b1; bignum b2; + int result; sexp = gcry_sexp_find_token(s1, what, 0); if (sexp == NULL) { @@ -1077,19 +1078,20 @@ static int _bignum_cmp(const gcry_sexp_t s1, sexp = gcry_sexp_find_token(s2, what, 0); if (sexp == NULL) { + bignum_free(b1); return 1; } b2 = gcry_sexp_nth_mpi(sexp, 1, GCRYMPI_FMT_USG); gcry_sexp_release(sexp); if (b2 == NULL) { + bignum_free(b1); return 1; } - if (bignum_cmp(b1, b2) != 0) { - return 1; - } - - return 0; + result = !! bignum_cmp(b1, b2); + bignum_free(b1); + bignum_free(b2); + return result; } int pki_key_compare(const ssh_key k1, -- 2.1.4
[PATCH 1/6] torture: Fix guard | Justus Winter <justus@xxxxxxxxxxx> |