#29044 [Asn->Csd]: compact function doesn't take account of infinitly recursive arrays
| From: | tony2001@php.net | Date: | Tue, 29 Jan 2008 08:55:25 +0000 |
| Subject: | #29044 [Asn->Csd]: compact function doesn't take account of infinitly recursive arrays | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121713@lists.php.net to get a copy of this message | ||
ID: 29044
Updated by: tony2001@php.net
Reported By: tomas_matousek at hotmail dot com
-Status: Assigned
+Status: Closed
Bug Type: Reproducible crash
Operating System: *
PHP Version: 5.2.5
Assigned To: nicholsr
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Yup, I commited the fix.
Previous Comments:
------------------------------------------------------------------------
[2008-01-26 01:08:47] jani@php.net
AFAICT, this was fixed today?
------------------------------------------------------------------------
[2008-01-24 12:08:10] nicholsr@php.net
Reopening this bug because I reproduced it today on 5.2.5 and on HEAD
and was about to raise my own bug for this. The problem is still
clearly present from code inspection. Since this bug was originally
raised the technique proposed by Tomas has been used successfully in
several other recursive array functions such as for example
array_walk_recursive and array_merge_recursive. I think compact could be
fixed in the same way.
I have a more extensive test case than the one Tomas supplied which I
will commit to head but not to the 5.3 and 5.2 branches (to avoid adding
breaking tests to stable branches.) The test case will be called
compact_variation1.phpt
------------------------------------------------------------------------
[2005-03-16 01:00:06] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2005-03-06 20:36:46] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2004-07-07 11:13:40] tomas_matousek at hotmail dot com
I don't think it very hard. You can add a flag to each array, e.g. bool
visited, which will be false on array creation. You set the flag to true
when going down the recursion and clears it on return. Than it suffice
to test whether the flag has been set.
Functions such print_r does detect recursion in some way.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/29044
--
Edit this bug report at http://bugs.php.net/?id=29044&edit=1