diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-10-07 15:58:07 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-10-07 15:58:07 +0200 |
commit | 02f3a10b5773b262b4bc61dfada485e7b3b7b5c7 (patch) | |
tree | 2637a182f081ade6a6195d068d71f71527b845f1 /src/util | |
parent | 5ed75a31aee2d1b799df713244205c75e923d286 (diff) |
more logging, handle cur aliasing in TALER_amount_set_zero()
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/amount.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util/amount.c b/src/util/amount.c index bb34b4eb4..2722da81a 100644 --- a/src/util/amount.c +++ b/src/util/amount.c @@ -243,17 +243,23 @@ enum GNUNET_GenericReturnValue TALER_amount_set_zero (const char *cur, struct TALER_Amount *amount) { + char tmp[TALER_CURRENCY_LEN]; size_t slen; if (GNUNET_OK != TALER_check_currency (cur)) return GNUNET_SYSERR; slen = strlen (cur); + /* make a copy of 'cur' to 'tmp' as the memset may clobber cur + if cur aliases &amount->currency! */ + memcpy (tmp, + cur, + slen); memset (amount, 0, sizeof (struct TALER_Amount)); for (unsigned int i = 0; i<slen; i++) - amount->currency[i] = cur[i]; + amount->currency[i] = tmp[i]; return GNUNET_OK; } |