Skip to content

Commit e996729

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Updated NEWS for #67693 Fixed bug #67693 - incorrect push to the empty array
2 parents aa3ddda + b3466f8 commit e996729

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

ext/standard/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
19851985
if (should_rehash) {
19861986
zend_hash_rehash(Z_ARRVAL_P(stack));
19871987
}
1988-
} else if (!key_len && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) {
1988+
} else if (!key_len && Z_ARRVAL_P(stack)->nNextFreeElement > 0 && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) {
19891989
Z_ARRVAL_P(stack)->nNextFreeElement = Z_ARRVAL_P(stack)->nNextFreeElement - 1;
19901990
}
19911991

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #67693 - incorrect push to empty array
3+
--FILE--
4+
<?php
5+
6+
$array = array(-1 => 0);
7+
8+
array_pop($array);
9+
10+
array_push($array, 0);
11+
array_push($array, 0);
12+
13+
var_dump($array);
14+
15+
echo"\nDone";
16+
?>
17+
--EXPECT--
18+
array(2) {
19+
[0]=>
20+
int(0)
21+
[1]=>
22+
int(0)
23+
}
24+
25+
Done

0 commit comments

Comments
 (0)