aboutsummaryrefslogtreecommitdiff
path: root/src/pki_gcrypt.c
diff options
context:
space:
mode:
authorJustus Winter <justus@g10code.com>2016-03-14 16:32:01 +0100
committerAndreas Schneider <asn@cryptomilk.org>2016-03-21 18:39:39 +0100
commitfc9434465c3836b6a6217e6635ab469fd478e7b0 (patch)
tree058b44b7793da62a53ae1f13cfb873c501b659cf /src/pki_gcrypt.c
parentba3ee9f0078187262edd2f68380f5e8b5454e247 (diff)
downloadlibssh-fc9434465c3836b6a6217e6635ab469fd478e7b0.tar.gz
libssh-fc9434465c3836b6a6217e6635ab469fd478e7b0.tar.xz
libssh-fc9434465c3836b6a6217e6635ab469fd478e7b0.zip
pki_gcrypt: Fix memory leak
* src/pki_gcrypt.c (_bignum_cmp): Fix memory leak. Signed-off-by: Justus Winter <justus@g10code.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/pki_gcrypt.c')
-rw-r--r--src/pki_gcrypt.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pki_gcrypt.c b/src/pki_gcrypt.c
index 663cb1ff..37188373 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,