commit 0bf1b319a5789826fbd5ff9f30efb0baba4edbf9
parent 4feb426272d362d0713e3548414da902f7144491
Author: Florian Dold <dold@taler.net>
Date: Tue, 17 Nov 2026 20:36:20 +0100
libexchange: initialize spare coin history entries before cleanup
Diffstat:
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/lib/exchange_api_get-coins-COIN_PUB-history.c b/src/lib/exchange_api_get-coins-COIN_PUB-history.c
@@ -1069,7 +1069,7 @@ TALER_EXCHANGE_parse_coin_history (
}
memset (rhistory,
0,
- sizeof (rhistory[0]) * len);
+ sizeof (rhistory[0]) * rlen);
if (GNUNET_OK !=
parse_coin_history (keys,
dk,
diff --git a/src/testing/testing_api_cmd_coin_history.c b/src/testing/testing_api_cmd_coin_history.c
@@ -456,7 +456,7 @@ coin_history_cb (struct HistoryState *ss,
hlen = json_array_size (rs->details.ok.history);
{
bool found[GNUNET_NZL (hlen)];
- struct TALER_EXCHANGE_CoinHistoryEntry rhist[GNUNET_NZL (hlen)];
+ struct TALER_EXCHANGE_CoinHistoryEntry rhist[hlen + 1];
struct AnalysisContext ac = {
.coin_pub = &ss->coin_pub,
.history = rhist,
@@ -479,6 +479,8 @@ coin_history_cb (struct HistoryState *ss,
memset (rhist,
0,
sizeof (rhist));
+ /* Exercise the public parse/free contract with spare capacity. */
+ rhist[hlen].type = TALER_EXCHANGE_CTT_MELT;
if (GNUNET_OK !=
TALER_EXCHANGE_parse_coin_history (
TALER_TESTING_get_keys (is),
@@ -487,7 +489,7 @@ coin_history_cb (struct HistoryState *ss,
&ss->coin_pub,
&total_in,
&total_out,
- hlen,
+ hlen + 1,
rhist))
{
GNUNET_break (0);
@@ -497,6 +499,7 @@ coin_history_cb (struct HistoryState *ss,
TALER_TESTING_interpreter_fail (ss->is);
return;
}
+ GNUNET_assert (TALER_EXCHANGE_CTT_NONE == rhist[hlen].type);
if (! check_melt_entries (ss,
hlen,
rhist))
@@ -556,7 +559,7 @@ coin_history_cb (struct HistoryState *ss,
}
#endif
cleanup:
- TALER_EXCHANGE_free_coin_history (hlen,
+ TALER_EXCHANGE_free_coin_history (hlen + 1,
rhist);
if (failed)
{