mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge Simon Arlott branch 'gnc-numeric-to-string-leaks'into stable #1695
This commit is contained in:
commit
fde47d1c7f
@ -474,9 +474,9 @@ check_credit_debit_balance (gpointer key, gpointer val, gpointer ud)
|
||||
*unbalanced |= !(gnc_numeric_zero_p (diff));
|
||||
|
||||
DEBUG ("%p | %s [%s - %s = %s]", key, result,
|
||||
gnc_numeric_to_string (tcds->debitSum),
|
||||
gnc_numeric_to_string (tcds->creditSum),
|
||||
gnc_numeric_to_string (diff));
|
||||
gnc_num_dbg_to_string (tcds->debitSum),
|
||||
gnc_num_dbg_to_string (tcds->creditSum),
|
||||
gnc_num_dbg_to_string (diff));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1141,7 +1141,7 @@ split_apply_exchange_rate (Split *split, GHashTable *bindings,
|
||||
if (exchange_rate_var != NULL)
|
||||
{
|
||||
exchange_rate = exchange_rate_var->value;
|
||||
DEBUG("exchange_rate is %s", gnc_numeric_to_string (exchange_rate));
|
||||
DEBUG("exchange_rate is %s", gnc_num_dbg_to_string (exchange_rate));
|
||||
}
|
||||
g_free (exchange_rate_var_name);
|
||||
|
||||
@ -1154,7 +1154,7 @@ split_apply_exchange_rate (Split *split, GHashTable *bindings,
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
|
||||
DEBUG("amount is %s for memo split '%s'", gnc_numeric_to_string (amt),
|
||||
DEBUG("amount is %s for memo split '%s'", gnc_num_dbg_to_string (amt),
|
||||
xaccSplitGetMemo (split));
|
||||
xaccSplitSetAmount(split, amt); /* marks split dirty */
|
||||
|
||||
@ -1318,7 +1318,7 @@ create_each_transaction_helper(Transaction *template_txn, void *user_data)
|
||||
creation_data);
|
||||
xaccSplitSetValue(copying_split, final);
|
||||
DEBUG("value is %s for memo split '%s'",
|
||||
gnc_numeric_to_string (final),
|
||||
gnc_num_dbg_to_string (final),
|
||||
xaccSplitGetMemo (copying_split));
|
||||
if (! gnc_commodity_equal(split_cmdty, txn_cmdty))
|
||||
{
|
||||
|
@ -1271,8 +1271,15 @@ xaccSplitSetValue (Split *s, gnc_numeric amt)
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if (gnc_numeric_check(new_val) == GNC_ERROR_OK &&
|
||||
!(gnc_numeric_zero_p (new_val) && !gnc_numeric_zero_p (amt)))
|
||||
{
|
||||
s->value = new_val;
|
||||
else PERR("numeric error %s in converting the split value's denominator with amount %s and denom %d", gnc_numeric_errorCode_to_string(gnc_numeric_check(new_val)), gnc_numeric_to_string(amt), get_currency_denom(s));
|
||||
}
|
||||
else
|
||||
{
|
||||
PERR("numeric error %s in converting the split value's denominator with amount %s and denom %d",
|
||||
gnc_numeric_errorCode_to_string(gnc_numeric_check(new_val)),
|
||||
gnc_num_dbg_to_string (amt), get_currency_denom(s));
|
||||
}
|
||||
|
||||
SET_GAINS_VDIRTY(s);
|
||||
mark_split (s);
|
||||
|
@ -1290,12 +1290,13 @@ gnc_num_dbg_to_string(gnc_numeric n)
|
||||
{
|
||||
static char buff[1000];
|
||||
static char *p = buff;
|
||||
static const uint64_t size = 50;
|
||||
static const size_t size = 50;
|
||||
int64_t tmpnum = n.num;
|
||||
int64_t tmpdenom = n.denom;
|
||||
|
||||
p += size;
|
||||
if (p - buff >= 1000) p = buff;
|
||||
if ((size_t)(p - buff) > (sizeof(buff) - size))
|
||||
p = buff;
|
||||
|
||||
snprintf(p, size, "%" PRId64 "/%" PRId64, tmpnum, tmpdenom);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user