We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d80be78 + 15bea9e commit 0410bf4Copy full SHA for 0410bf4
ext/standard/array.c
@@ -2996,6 +2996,10 @@ PHP_FUNCTION(range)
2996
step = Z_LVAL_P(user_step);
2997
/* We only want positive step values. */
2998
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
+ }
3003
is_step_negative = true;
3004
step *= -1;
3005
}
ext/standard/tests/array/gh14775.phpt
@@ -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