]> granicus.if.org Git - php/commitdiff
Fixed bug #69758 (Item added to array not being removed by array_pop/shift)
authorXinchen Hui <laruence@php.net>
Fri, 5 Jun 2015 03:54:22 +0000 (11:54 +0800)
committerXinchen Hui <laruence@php.net>
Fri, 5 Jun 2015 03:54:22 +0000 (11:54 +0800)
NEWS
Zend/tests/bug69758.phpt [new file with mode: 0644]
Zend/zend_hash.c

diff --git a/NEWS b/NEWS
index 81242d12a8ca2953aed68bf3481e233b82df3dd6..ecd70bba9d763ef8b5e84c2f137086ab13a39a3d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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 (file)
index 0000000..f0b3588
--- /dev/null
@@ -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) {
+}
index 76804b0ab58937528ec6c83c4fbfe9a0b7607a10..bb0a2ff24a6e0fd3b5b4627024a7bba0e38517af 100644 (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;