summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_refresh.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-03 11:17:29 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-03 11:17:40 +0200
commit91ef87a804d34f535ef97b6caa7fbd6c327550e8 (patch)
tree71588595ae24231fd657d7e38e386be790af5a08 /src/lib/exchange_api_refresh.c
parent256910e28d27e774c49ce1349733b456e6d07418 (diff)
downloadexchange-91ef87a804d34f535ef97b6caa7fbd6c327550e8.tar.gz
exchange-91ef87a804d34f535ef97b6caa7fbd6c327550e8.tar.bz2
exchange-91ef87a804d34f535ef97b6caa7fbd6c327550e8.zip
fix potential free of uninitialized ptr, (on virtually impossible error handling path)
Diffstat (limited to 'src/lib/exchange_api_refresh.c')
-rw-r--r--src/lib/exchange_api_refresh.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/lib/exchange_api_refresh.c b/src/lib/exchange_api_refresh.c
index ec9c1d992..e2a3a245a 100644
--- a/src/lib/exchange_api_refresh.c
+++ b/src/lib/exchange_api_refresh.c
@@ -246,7 +246,7 @@ free_melt_data (struct MeltData *md)
}
for (unsigned int i=0;i<TALER_CNC_KAPPA;i++)
- GNUNET_free (md->fresh_coins[i]);
+ GNUNET_free_non_null (md->fresh_coins[i]);
/* Finally, clean up a bit...
(NOTE: compilers might optimize this away, so this is
not providing any strong assurances that the key material
@@ -705,6 +705,7 @@ TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_pr
GNUNET_CRYPTO_eddsa_key_get_public (&melt_priv->eddsa_priv,
&coin_pub.eddsa_pub);
/* build up melt data structure */
+ memset (&md, 0, sizeof (md));
md.num_fresh_coins = fresh_pks_len;
md.melted_coin.coin_priv = *melt_priv;
md.melted_coin.melt_amount_with_fee = *melt_amount;
@@ -713,8 +714,8 @@ TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_pr
md.melted_coin.expire_deposit
= melt_pk->expire_deposit;
GNUNET_assert (GNUNET_OK ==
- TALER_amount_get_zero (melt_amount->currency,
- &total));
+ TALER_amount_get_zero (melt_amount->currency,
+ &total));
md.melted_coin.pub_key.rsa_public_key
= GNUNET_CRYPTO_rsa_public_key_dup (melt_pk->key.rsa_public_key);
md.melted_coin.sig.rsa_signature
@@ -726,13 +727,13 @@ TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_pr
md.fresh_pks[i].rsa_public_key
= GNUNET_CRYPTO_rsa_public_key_dup (fresh_pks[i].key.rsa_public_key);
if ( (GNUNET_OK !=
- TALER_amount_add (&total,
- &total,
- &fresh_pks[i].value)) ||
- (GNUNET_OK !=
- TALER_amount_add (&total,
- &total,
- &fresh_pks[i].fee_withdraw)) )
+ TALER_amount_add (&total,
+ &total,
+ &fresh_pks[i].value)) ||
+ (GNUNET_OK !=
+ TALER_amount_add (&total,
+ &total,
+ &fresh_pks[i].fee_withdraw)) )
{
GNUNET_break (0);
free_melt_data (&md);
@@ -742,7 +743,7 @@ TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_pr
/* verify that melt_amount is above total cost */
if (1 ==
TALER_amount_cmp (&total,
- melt_amount) )
+ melt_amount) )
{
/* Eh, this operation is more expensive than the
@a melt_amount. This is not OK. */