Bug #71154 [Opn->Csd]: Incorrect HT iterator invalidation causes iterator reuse
| From: | nikic@php.net | Date: | Thu, 17 Dec 2015 21:21:18 +0000 |
| Subject: | Bug #71154 [Opn->Csd]: Incorrect HT iterator invalidation causes iterator reuse | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197979@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71154&edit=1
ID: 71154
Updated by: nikic@php.net
Reported by: nikic@php.net
Summary: Incorrect HT iterator invalidation causes iterator
reuse
-Status: Open
+Status: Closed
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.0Git-2015-12-17 (Git)
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6a4c02e107e86a0ff700b79f5a9da0f383c06430
Log: Fixed bug #71154
Previous Comments:
------------------------------------------------------------------------
[2015-12-17 20:35:05] nikic@php.net
Description:
------------
When iterators are removed on HT destruction we NULL out iter->ht entries. This will allow the
iter to be reused. However it may still be in use by the foreach loop. In this case one iter will be
shared between two loops/iterators.
Test script:
---------------
<?php
$array = [1, 2, 3];
foreach ($array as &$ref) {
/* Free array, causing free of iterator */
$array = [];
/* Reuse the iterator.
* However it will also be reused on next foreach iteration */
$it = new ArrayIterator([1, 2, 3]);
$it->rewind();
}
var_dump($it->current());
Expected result:
----------------
int(1)
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71154&edit=1