diff --git a/ext/standard/array.c b/ext/standard/array.c index 6c6f40f0789..068057e70a9 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2996,6 +2996,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 00000000000..df4db76031e --- /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