mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Catch std::underflow_error as well as std::overflow_error.
Any operation that can overflow will throw an underflow if it's a negative number. The C interface needs to catch both to prevent unhandled exception crashes,
This commit is contained in:
parent
6d2ef90313
commit
87533fe4bc
@ -391,6 +391,13 @@ GncNumeric::to_decimal(unsigned int max_places) const
|
||||
<< " overflows when attempting to convert it to decimal.\n";
|
||||
throw std::range_error(msg.str());
|
||||
}
|
||||
catch (const std::underflow_error& err)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "GncNumeric " << *this
|
||||
<< " underflows when attempting to convert it to decimal.\n";
|
||||
throw std::range_error(msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -998,6 +1005,10 @@ gnc_numeric_convert(gnc_numeric in, int64_t denom, int how)
|
||||
{
|
||||
return gnc_numeric_error(GNC_ERROR_OVERFLOW);
|
||||
}
|
||||
catch (const std::underflow_error& err)
|
||||
{
|
||||
return gnc_numeric_error(GNC_ERROR_OVERFLOW);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user