From fd51bc523d095168ee9367fe3f18d18f7a88ad90 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 21 Aug 2020 11:53:10 +0900 Subject: tests: Fix basic.c. * tests/basic.c (check_one_hmac): Fix error paths. (check_pubkey_crypt): Fix wrong call of gcry_sexp_new. Signed-off-by: NIIBE Yutaka --- tests/basic.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/basic.c b/tests/basic.c index ea13c50a..fdc5df4b 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -11550,18 +11550,19 @@ check_one_hmac (int algo, const char *data, int datalen, gcry_md_write (hd, data, datalen); err = gcry_md_copy (&hd2, hd); + + gcry_md_close (hd); + if (err) { fail ("algo %d, gcry_md_copy failed: %s\n", algo, gpg_strerror (err)); + return; } - gcry_md_close (hd); - p = gcry_md_read (hd2, algo); if (!p) fail("algo %d, hmac gcry_md_read failed\n", algo); - - if (memcmp (p, expect, mdlen)) + else if (memcmp (p, expect, mdlen)) { printf ("computed: "); for (i = 0; i < mdlen; i++) @@ -13420,8 +13421,8 @@ check_pubkey_crypt (int n, gcry_sexp_t skey, gcry_sexp_t pkey, int algo) gcry_sexp_t list; /* Convert decoding hint into canonical sexp. */ - hint_len = gcry_sexp_new (&list, datas[dataidx].hint, - strlen (datas[dataidx].hint), 1); + gcry_sexp_new (&list, datas[dataidx].hint, + strlen (datas[dataidx].hint), 1); hint_len = gcry_sexp_sprint (list, GCRYSEXP_FMT_CANON, NULL, 0); hint = gcry_malloc (hint_len); if (!hint) -- cgit v1.2.1