diff options
author | Xinchen Hui <laruence@php.net> | 2015-06-05 11:54:22 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2015-06-05 11:54:22 +0800 |
commit | 497f9f2cda4e2f2281cfbde148e7408908261c63 (patch) | |
tree | 009db8f73fcd7bb1ea60a1773e6ad7709f8d36e0 | |
parent | c6db18f9ab0f512df573bca9538f1aace9a1a6d2 (diff) | |
download | php-git-497f9f2cda4e2f2281cfbde148e7408908261c63.tar.gz |
Fixed bug #69758 (Item added to array not being removed by array_pop/shift)
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | Zend/tests/bug69758.phpt | 27 | ||||
-rw-r--r-- | Zend/zend_hash.c | 2 |
3 files changed, 30 insertions, 1 deletions
@@ -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) diff --git a/Zend/tests/bug69758.phpt b/Zend/tests/bug69758.phpt new file mode 100644 index 0000000000..f0b3588139 --- /dev/null +++ b/Zend/tests/bug69758.phpt @@ -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) { +} diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 76804b0ab5..bb0a2ff24a 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -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; |