summaryrefslogtreecommitdiff
path: root/eval_error.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-15 09:03:03 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-15 09:03:03 +0000
commit06e2873ed1cd8dca1bff6b87ae59b9ffa7ae4754 (patch)
treed0c17a634342fa27d84ebb6550aa98da2efd830e /eval_error.c
parentb7f5c573ef20dbbf5534ee3a45625c7f9d45f2ec (diff)
eval_error.c: log10(0) is ERANGE
By definition, the logarithm of 0 is negative infinity. This is a pole error (cf: cf: ISO/IEC 9899:1999 section 7.12.1 paragraph 3) and of course, cannot fit into an `int` value. We have to resort to INT_MIN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_error.c')
-rw-r--r--eval_error.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/eval_error.c b/eval_error.c
index 82ada4dc40..8aab7ba05d 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -195,7 +195,7 @@ print_backtrace(const VALUE eclass, const VALUE errat, const VALUE str, int reve
long len = RARRAY_LEN(errat);
int skip = eclass == rb_eSysStackError;
const int threshold = 1000000000;
- int width = ((int)log10((double)(len > threshold ?
+ int width = (len <= 1) ? INT_MIN : ((int)log10((double)(len > threshold ?
((len - 1) / threshold) :
len - 1)) +
(len < threshold ? 0 : 9) + 1);