]> granicus.if.org Git - php/commitdiff
Fixed bug #71153
authorNikita Popov <nikic@php.net>
Thu, 17 Dec 2015 19:59:57 +0000 (20:59 +0100)
committerNikita Popov <nikic@php.net>
Thu, 17 Dec 2015 19:59:57 +0000 (20:59 +0100)
NEWS
ext/spl/spl_array.c
ext/spl/tests/bug71153.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 86a6345953fcae4b5be3d00686cc7ec120915eb1..16a91ab5a3845520fb1cb8655ff231b752b137bf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -44,6 +44,8 @@ PHP                                                                        NEWS
 - SPL:
   . Fixed bug #71077 (ReflectionMethod for ArrayObject constructor returns
     wrong number of parameters). (Laruence)
+  . Fixed bug #71153 (Performance Degradation in ArrayIterator with large
+    arrays). (Nikita)
 
 17 Dec 2015, PHP 7.0.1
 
index 0329270060e7bc1d8e932c984291362212e9b764..31d5beaa39f8a813c7152a65c39fdb82e29b77f7 100644 (file)
@@ -130,6 +130,10 @@ static zend_always_inline uint32_t *spl_array_get_pos_ptr(HashTable *ht, spl_arr
 static void spl_array_object_free_storage(zend_object *object)
 {
        spl_array_object *intern = spl_array_from_obj(object);
+       
+       if (intern->ht_iter != (uint32_t) -1) {
+               zend_hash_iterator_del(intern->ht_iter);
+       }
 
        zend_object_std_dtor(&intern->std);
 
diff --git a/ext/spl/tests/bug71153.phpt b/ext/spl/tests/bug71153.phpt
new file mode 100644 (file)
index 0000000..bdd940c
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #71153: Performance Degradation in ArrayIterator with large arrays
+--FILE--
+<?php
+
+$n = 200000;
+
+for ($i = 0; $i < $n; ++$i) {
+    foreach (new ArrayIterator([]) as $v) {}
+}
+
+echo "done\n";
+
+?>
+--EXPECT--
+done