mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-26 02:40:43 -06:00
Calling sigfigs_denom with a zero crashes due to a divide by zero.
This commit is contained in:
parent
6933ab765d
commit
cdc94c7131
@ -280,6 +280,9 @@ GncNumeric::prepare_conversion(int64_t new_denom) const
|
||||
int64_t
|
||||
GncNumeric::sigfigs_denom(unsigned figs) const noexcept
|
||||
{
|
||||
if (m_num == 0)
|
||||
return 1;
|
||||
|
||||
int64_t num_abs{std::abs(m_num)};
|
||||
bool not_frac = num_abs > m_den;
|
||||
int64_t val{ not_frac ? num_abs / m_den : m_den / num_abs };
|
||||
|
@ -159,6 +159,9 @@ GncRational::prepare_conversion (GncInt128 new_denom) const
|
||||
GncInt128
|
||||
GncRational::sigfigs_denom(unsigned figs) const noexcept
|
||||
{
|
||||
if (m_num == 0)
|
||||
return 1;
|
||||
|
||||
auto num_abs = m_num.abs();
|
||||
bool not_frac = num_abs > m_den;
|
||||
int64_t val{ not_frac ? num_abs / m_den : m_den / num_abs };
|
||||
|
Loading…
Reference in New Issue
Block a user