Skip to content

Commit 0410bf4

Browse files
committed
Merge branch 'PHP-8.3'
2 parents d80be78 + 15bea9e commit 0410bf4

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

ext/standard/array.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,6 +2996,10 @@ PHP_FUNCTION(range)
29962996
step = Z_LVAL_P(user_step);
29972997
/* We only want positive step values. */
29982998
if (step < 0) {
2999+
if (UNEXPECTED(step == ZEND_LONG_MIN)) {
3000+
zend_argument_value_error(3, "must be greater than " ZEND_LONG_FMT, step);
3001+
RETURN_THROWS();
3002+
}
29993003
is_step_negative = true;
30003004
step *= -1;
30013005
}

ext/standard/tests/array/gh14775.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-14775: Range negative step overflow
3+
--FILE--
4+
<?php
5+
$var = -PHP_INT_MAX - 1;
6+
try {
7+
range($var,1,$var);
8+
} catch (\ValueError $e) {
9+
echo $e->getMessage() . PHP_EOL;
10+
}
11+
--EXPECTF--
12+
range(): Argument #3 ($step) must be greater than %s

0 commit comments

Comments
 (0)