1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

Fixed bug #69758 (Item added to array not being removed by array_pop/shift)

This commit is contained in:
Xinchen Hui
2015-06-05 11:54:22 +08:00
parent c6db18f9ab
commit 497f9f2cda
3 changed files with 30 additions and 1 deletions

2
NEWS
View File

@@ -9,6 +9,8 @@
. Added support for SEARCH WebDav method. (Mats Lindh)
- Core:
. Fixed bug #69758 (Item added to array not being removed by array_pop/shift
). (Laruence)
. Fixed bug #68475 (Add support for $callable() sytnax with 'Class::method').
(Julien, Aaron Piotrowski)
. Fixed bug #69485 (Double free on zend_list_dtor). (Laruence)

27
Zend/tests/bug69758.phpt Normal file
View File

@@ -0,0 +1,27 @@
--TEST--
Bug #69758 (Item added to array not being removed by array_pop/shift)
--FILE--
<?php
$tokens = array();
$conditions = array();
for ($i = 0; $i <= 10; $i++) {
$tokens[$i] = $conditions;
// First integer must be less than 8
// and second must be 8, 9 or 10
if ($i !== 0 && $i !== 8) {
continue;
}
// Add condition and then pop off straight away.
// Can also use array_shift() here.
$conditions[$i] = true;
$oldCondition = array_pop($conditions);
}
// Conditions should be empty.
var_dump($conditions);
?>
--EXPECT--
array(0) {
}

View File

@@ -1698,7 +1698,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
target->pDestructor = source->pDestructor;
if (source->nNumUsed == 0) {
target->u.flags = (source->u.flags & ~(HASH_FLAG_INITIALIZED|HASH_FLAG_PERSISTENT)) | HASH_FLAG_APPLY_PROTECTION | HASH_FLAG_STATIC_KEYS;
target->u.flags = (source->u.flags & ~(HASH_FLAG_INITIALIZED|HASH_FLAG_PACKED|HASH_FLAG_PERSISTENT)) | HASH_FLAG_APPLY_PROTECTION | HASH_FLAG_STATIC_KEYS;
target->nTableMask = HT_MIN_MASK;
target->nNumUsed = 0;
target->nNumOfElements = 0;