diff --git a/ext/standard/array.c b/ext/standard/array.c index 30868a47b5932..b6f78fad28611 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2887,6 +2887,10 @@ PHP_FUNCTION(range) step = Z_LVAL_P(user_step); /* We only want positive step values. */ if (step < 0) { + if (UNEXPECTED(step == ZEND_LONG_MIN)) { + zend_argument_value_error(3, "must be greater than " ZEND_LONG_FMT, step); + RETURN_THROWS(); + } is_step_negative = true; step *= -1; } diff --git a/ext/standard/tests/array/gh14775.phpt b/ext/standard/tests/array/gh14775.phpt new file mode 100644 index 0000000000000..df4db76031ecb --- /dev/null +++ b/ext/standard/tests/array/gh14775.phpt @@ -0,0 +1,12 @@ +--TEST-- +GH-14775: Range negative step overflow +--FILE-- +getMessage() . PHP_EOL; +} +--EXPECTF-- +range(): Argument #3 ($step) must be greater than %s