Skip to content

Commit 5e34bb8

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-13094: range(9.9, '0') causes segmentation fault
2 parents 4cda181 + 1d6f344 commit 5e34bb8

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

ext/standard/array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,8 +2924,8 @@ PHP_FUNCTION(range)
29242924

29252925
/* If the range is given as strings, generate an array of characters. */
29262926
if (start_type >= IS_STRING || end_type >= IS_STRING) {
2927-
/* If one of the inputs is NOT a string */
2928-
if (UNEXPECTED(start_type + end_type < 2*IS_STRING)) {
2927+
/* If one of the inputs is NOT a string nor single-byte string */
2928+
if (UNEXPECTED(start_type < IS_STRING || end_type < IS_STRING)) {
29292929
if (start_type < IS_STRING) {
29302930
if (end_type != IS_ARRAY) {
29312931
php_error_docref(NULL, E_WARNING, "Argument #1 ($start) must be a single byte string if"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
GH-13094 (range(9.9, '0') causes segmentation fault)
3+
--FILE--
4+
<?php
5+
var_dump(range(9.9, '0'));
6+
?>
7+
--EXPECT--
8+
array(10) {
9+
[0]=>
10+
float(9.9)
11+
[1]=>
12+
float(8.9)
13+
[2]=>
14+
float(7.9)
15+
[3]=>
16+
float(6.9)
17+
[4]=>
18+
float(5.9)
19+
[5]=>
20+
float(4.9)
21+
[6]=>
22+
float(3.9000000000000004)
23+
[7]=>
24+
float(2.9000000000000004)
25+
[8]=>
26+
float(1.9000000000000004)
27+
[9]=>
28+
float(0.9000000000000004)
29+
}

0 commit comments

Comments
 (0)