diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-19 20:56:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-19 20:56:53 +0100 |
commit | 52fe9d657bd54e622e8b87070c29ac0ffc27c575 (patch) | |
tree | 37d6b3cd84bff3e45b13b22b09d9ca938073c9fd /src/util/test_helper_rsa.c | |
parent | 7b5eb6137061128f987260ba681231e28ae260d5 (diff) | |
download | exchange-52fe9d657bd54e622e8b87070c29ac0ffc27c575.tar.xz |
-fix leaks and compiler warnings
Diffstat (limited to 'src/util/test_helper_rsa.c')
-rw-r--r-- | src/util/test_helper_rsa.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/util/test_helper_rsa.c b/src/util/test_helper_rsa.c index c98a678b8..21840eb49 100644 --- a/src/util/test_helper_rsa.c +++ b/src/util/test_helper_rsa.c @@ -99,6 +99,22 @@ static struct KeyData keys[MAX_KEYS]; /** + * Release memory occupied by #keys. + */ +static void +free_keys (void) +{ + for (unsigned int i = 0; i<MAX_KEYS; i++) + if (keys[i].valid) + { + TALER_denom_pub_free (&keys[i].denom_pub); + GNUNET_assert (num_keys > 0); + num_keys--; + } +} + + +/** * Function called with information about available keys for signing. Usually * only called once per key upon connect. Also called again in case a key is * being revoked, in that case with an @a end_time of zero. Stores the keys @@ -127,6 +143,7 @@ key_cb (void *cls, const struct TALER_SecurityModulePublicKeyP *sm_pub, const struct TALER_SecurityModuleSignatureP *sm_sig) { + (void) cls; (void) sm_pub; (void) sm_sig; GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -472,9 +489,6 @@ par_signing (struct GNUNET_CONFIGURATION_Handle *cfg) for (unsigned int i = 0; i<NUM_CORES; i++) { pids[i] = fork (); - memset (keys, - 0, - sizeof (keys)); num_keys = 0; GNUNET_assert (-1 != pids[i]); if (0 == pids[i]) @@ -488,6 +502,7 @@ par_signing (struct GNUNET_CONFIGURATION_Handle *cfg) ret = perf_signing (dh, "parallel"); TALER_CRYPTO_helper_rsa_disconnect (dh); + free_keys (); exit (ret); } } @@ -571,16 +586,10 @@ run_test (void) ret = perf_signing (dh, "sequential"); TALER_CRYPTO_helper_rsa_disconnect (dh); + free_keys (); if (0 == ret) ret = par_signing (cfg); /* clean up our state */ - for (unsigned int i = 0; i<MAX_KEYS; i++) - if (keys[i].valid) - { - TALER_denom_pub_free (&keys[i].denom_pub); - GNUNET_assert (num_keys > 0); - num_keys--; - } GNUNET_CONFIGURATION_destroy (cfg); return ret; } |