Skip to content

Commit fc470b6

Browse files
committed
Fixed #74100 - Fixed array_fill behaviour with negative $start_index
1 parent 3917350 commit fc470b6

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

ext/standard/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1980,8 +1980,8 @@ PHP_FUNCTION(array_fill)
19801980
}
19811981
zend_hash_index_add_new(Z_ARRVAL_P(return_value), start_key, val);
19821982
while (--num) {
1983-
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), val);
19841983
start_key++;
1984+
zend_hash_index_add_new(Z_ARRVAL_P(return_value), start_key, val);
19851985
}
19861986
}
19871987
} else if (EXPECTED(num == 0)) {

ext/standard/tests/array/array_fill_variation1_64bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ array(2) {
120120
array(2) {
121121
[-10]=>
122122
int(100)
123-
[0]=>
123+
[-9]=>
124124
int(100)
125125
}
126126
-- Iteration 3 --
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #72369 (array_merge() produces references in PHP7)
3+
--FILE--
4+
<?php
5+
var_dump(array_fill_keys(range(-2,1), true));
6+
var_dump(array_fill(-2, 4, true));
7+
?>
8+
--EXPECT--
9+
array(4) {
10+
[-2]=>
11+
bool(true)
12+
[-1]=>
13+
bool(true)
14+
[0]=>
15+
bool(true)
16+
[1]=>
17+
bool(true)
18+
}
19+
array(4) {
20+
[-2]=>
21+
bool(true)
22+
[-1]=>
23+
bool(true)
24+
[0]=>
25+
bool(true)
26+
[1]=>
27+
bool(true)
28+
}
29+

0 commit comments

Comments
 (0)