diff options
author | Tjerk Meesters <datibbaw@php.net> | 2014-07-30 18:27:29 +0800 |
---|---|---|
committer | Tjerk Meesters <datibbaw@php.net> | 2014-07-30 18:27:29 +0800 |
commit | f9258929201616750d418c629f7afdcfdab7dada (patch) | |
tree | 430928bd8e5d2c5cd482eb6a080825e10fc65d20 | |
parent | 8e13e502679fe6b8a1a8289d71b214684242e07e (diff) | |
parent | 52f4587e8a7a977909ea96c6ea9e27718d87b227 (diff) | |
download | php-git-f9258929201616750d418c629f7afdcfdab7dada.tar.gz |
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
Updated NEWS for #67693
Fixed bug #67693 - incorrect push to the empty array
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/standard/array.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/array/bug67693.phpt | 25 |
3 files changed, 29 insertions, 1 deletions
@@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2014, PHP 5.6.0 Release Candidate 4 +- Core: + . Fixed bug #67693 (incorrect push to the empty array) (Tjerk) + 31 Jul 2014, PHP 5.6.0 Release Candidate 3 - Core: diff --git a/ext/standard/array.c b/ext/standard/array.c index cbcaaf5b8b..2792b86f02 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1893,7 +1893,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end) /* If we did a shift... re-index like it did before */ if (!off_the_end) { zend_hash_reindex(Z_ARRVAL_P(stack), 1); - } else if (!key_len && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) { + } else if (!key_len && Z_ARRVAL_P(stack)->nNextFreeElement > 0 && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) { Z_ARRVAL_P(stack)->nNextFreeElement = Z_ARRVAL_P(stack)->nNextFreeElement - 1; } diff --git a/ext/standard/tests/array/bug67693.phpt b/ext/standard/tests/array/bug67693.phpt new file mode 100644 index 0000000000..516436c511 --- /dev/null +++ b/ext/standard/tests/array/bug67693.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #67693 - incorrect push to empty array +--FILE-- +<?php + +$array = array(-1 => 0); + +array_pop($array); + +array_push($array, 0); +array_push($array, 0); + +var_dump($array); + +echo"\nDone"; +?> +--EXPECT-- +array(2) { + [0]=> + int(0) + [1]=> + int(0) +} + +Done |