mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Prevent infinite loop in to_decimal if numerator becomes 0.
Also immediately return 0 if this is 0.
This commit is contained in:
parent
9948ee6235
commit
72f95238fb
@ -321,6 +321,10 @@ GncNumeric::to_decimal(unsigned int max_places) const
|
|||||||
{
|
{
|
||||||
if (max_places > max_leg_digits)
|
if (max_places > max_leg_digits)
|
||||||
max_places = max_leg_digits;
|
max_places = max_leg_digits;
|
||||||
|
|
||||||
|
if (m_num == 0)
|
||||||
|
return GncNumeric();
|
||||||
|
|
||||||
if (is_decimal())
|
if (is_decimal())
|
||||||
{
|
{
|
||||||
if (m_num == 0 || m_den < powten(max_places))
|
if (m_num == 0 || m_den < powten(max_places))
|
||||||
@ -350,7 +354,7 @@ GncNumeric::to_decimal(unsigned int max_places) const
|
|||||||
rr_num *= factor;
|
rr_num *= factor;
|
||||||
rr_den *= factor;
|
rr_den *= factor;
|
||||||
}
|
}
|
||||||
while (rr_num % 10 == 0)
|
while (!rr_num.isZero() && rr_num % 10 == 0)
|
||||||
{
|
{
|
||||||
rr_num /= 10;
|
rr_num /= 10;
|
||||||
rr_den /= 10;
|
rr_den /= 10;
|
||||||
|
Loading…
Reference in New Issue
Block a user