Avoid SIGFPE due to modulo-by-zero is the requested number of significant

figures is greater than log10(2^63).
BP


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14512 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2006-07-15 19:47:02 +00:00
parent e3f064f002
commit f0d64c1185

View File

@ -785,6 +785,9 @@ gnc_numeric_convert(gnc_numeric in, gint64 denom, gint how)
} }
sigfigs = GNC_HOW_GET_SIGFIGS(how); sigfigs = GNC_HOW_GET_SIGFIGS(how);
if (fabs(sigfigs - logratio) > 18)
return gnc_numeric_error(GNC_ERROR_OVERFLOW);
if(sigfigs-logratio >= 0) { if(sigfigs-logratio >= 0) {
denom = (gint64)(pow(10, sigfigs-logratio)); denom = (gint64)(pow(10, sigfigs-logratio));
} }