summaryrefslogtreecommitdiff
path: root/cipher
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-03-23 18:21:53 +0100
committerWerner Koch <wk@gnupg.org>2016-03-24 17:02:34 +0100
commit4a064e2a06fe737f344d1dfd8a45cc4c2abbe4c9 (patch)
tree3bb1f2e8dd754b87b4eeda2371d39a2b231ce058 /cipher
parent470a30db241a2d567739ef2adb2a2ee64992d8b4 (diff)
downloadlibgcrypt-master.tar.gz
cipher: Fix memleaks in (self)tests.HEADmaster
* cipher/dsa.c: Release memory for MPI and sexp structures. * cipher/ecc.c: Release memory for sexp structure. * tests/keygen.c: Likewise. -- These leaks broke the mpitests, basic and keygen tests when running under AddressSanitizer. Signed-off-by: Peter Wu <peter@lekensteyn.nl> Minor formatting changes by -wk.
Diffstat (limited to 'cipher')
-rw-r--r--cipher/dsa.c7
-rw-r--r--cipher/ecc.c1
2 files changed, 8 insertions, 0 deletions
diff --git a/cipher/dsa.c b/cipher/dsa.c
index 909a8ca2..22d8d782 100644
--- a/cipher/dsa.c
+++ b/cipher/dsa.c
@@ -1255,6 +1255,7 @@ selftest_sign (gcry_sexp_t pkey, gcry_sexp_t skey)
if (!calculated_r)
goto leave;
+ sexp_release (l2);
l2 = _gcry_sexp_find_token (l1, "s", 0);
if (!l2)
goto leave;
@@ -1289,6 +1290,12 @@ selftest_sign (gcry_sexp_t pkey, gcry_sexp_t skey)
leave:
+ _gcry_mpi_release (calculated_s);
+ _gcry_mpi_release (calculated_r);
+ _gcry_mpi_release (s);
+ _gcry_mpi_release (r);
+ sexp_release (l2);
+ sexp_release (l1);
sexp_release (sig);
sexp_release (data_bad);
sexp_release (data);
diff --git a/cipher/ecc.c b/cipher/ecc.c
index 5b035306..8dbf5bd0 100644
--- a/cipher/ecc.c
+++ b/cipher/ecc.c
@@ -2046,6 +2046,7 @@ selftest_sign (gcry_sexp_t pkey, gcry_sexp_t skey)
if (!calculated_r)
goto leave;
+ sexp_release (l2);
l2 = _gcry_sexp_find_token (l1, "s", 0);
if (!l2)
goto leave;