diff options
author | Nuno Lopes <nlopess@php.net> | 2012-05-11 12:50:29 -0400 |
---|---|---|
committer | Nuno Lopes <nlopess@php.net> | 2012-05-11 13:07:00 -0400 |
commit | 950d5ee590214742799836d3d939ee59f641bdf4 (patch) | |
tree | 7125569c1006ad21a202f30f153e1ce051c0bcb2 | |
parent | 81ba6b14c7b1b934f4d3e2896f861a42b07aa838 (diff) | |
download | php-git-950d5ee590214742799836d3d939ee59f641bdf4.tar.gz |
fix stack overflow in php_intlog10abs()
bug uncovered by LLVM/clang's new -fbounds-checking switch
this patch fixes a crash in ext/standard/tests/math/round_large_exp.phpt
-rw-r--r-- | ext/standard/math.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/standard/math.c b/ext/standard/math.c index 21c730c928..749c77c75c 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -37,7 +37,7 @@ static inline int php_intlog10abs(double value) { int result; value = fabs(value); - if (value < 1e-8 || value > 1e23) { + if (value < 1e-8 || value > 1e22) { result = (int)floor(log10(value)); } else { static const double values[] = { @@ -46,7 +46,7 @@ static inline int php_intlog10abs(double value) { 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; /* Do a binary search with 5 steps */ - result = 16; + result = 15; if (value < values[result]) { result -= 8; } else { |