Bug #71073 [Opn->Nab]: Foreach behaviour changes allow for infinite loops
| From: | nikic@php.net | Date: | Wed, 09 Dec 2015 09:48:43 +0000 |
| Subject: | Bug #71073 [Opn->Nab]: Foreach behaviour changes allow for infinite loops | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197727@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71073&edit=1
ID: 71073
Updated by: nikic@php.net
Reported by: ljsteadman at gmail dot com
Summary: Foreach behaviour changes allow for infinite loops
-Status: Open
+Status: Not a bug
Type: Bug
Package: Performance problem
Operating System: Any
PHP Version: 7.0.0
Block user comment: N
Private report: N
New Comment:
Foreach could always produce infinite loops. Both through iterators (InfiniteIterator), but also for
arrays. The modifications you had to do were only different previously.
If you don't want an infinite loop, don't grow your array infinitely...
Previous Comments:
------------------------------------------------------------------------
[2015-12-09 09:42:57] ljsteadman at gmail dot com
Description:
------------
The latest behaviour changes to foreach means that if an element is pushed onto the array during
iteration with a unique key, it will infinite loop.
Test script:
---------------
https://3v4l.org/ATFK9
Expected result:
----------------
foreach shouldn't produce a infinite loop.
Actual result:
--------------
foreach continues to iterate until it runs out of memory, thus producing an infinite loop.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71073&edit=1