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

Merge branch 'PHP-8.1'

* PHP-8.1:
  Fix GH-8366: ArrayIterator may leak when calling __construct()
This commit is contained in:
Christoph M. Becker
2022-04-15 19:10:29 +02:00
2 changed files with 13 additions and 1 deletions

View File

@@ -1036,7 +1036,10 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar
intern->ar_flags &= ~SPL_ARRAY_IS_SELF & ~SPL_ARRAY_USE_OTHER;
intern->ar_flags |= ar_flags;
intern->ht_iter = (uint32_t)-1;
if (intern->ht_iter != (uint32_t)-1) {
zend_hash_iterator_del(intern->ht_iter);
intern->ht_iter = (uint32_t)-1;
}
}
/* }}} */

View File

@@ -0,0 +1,9 @@
--TEST--
Bug GH-8366 (ArrayIterator may leak when calling __construct())
--FILE--
<?php
$it = new \ArrayIterator();
foreach ($it as $elt) {}
$it->__construct([]);
?>
--EXPECT--