Skip to content

Commit 5c87ca2

Browse files
committed
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
1 parent d0d7340 commit 5c87ca2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/standard/math.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static inline int php_intlog10abs(double value) {
3737
int result;
3838
value = fabs(value);
3939

40-
if (value < 1e-8 || value > 1e23) {
40+
if (value < 1e-8 || value > 1e22) {
4141
result = (int)floor(log10(value));
4242
} else {
4343
static const double values[] = {
@@ -46,7 +46,7 @@ static inline int php_intlog10abs(double value) {
4646
1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
4747
1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22};
4848
/* Do a binary search with 5 steps */
49-
result = 16;
49+
result = 15;
5050
if (value < values[result]) {
5151
result -= 8;
5252
} else {

0 commit comments

Comments
 (0)