ID: 29044 User updated by: tomas_matousek at hotmail dot com Reported By: tomas_matousek at hotmail dot com Status: Open Bug Type: Reproducible crash Operating System: * PHP Version: 5.0.0RC3 New Comment:
I don't think it is 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. Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2004-07-07 11:05:41] [EMAIL PROTECTED] Nothing much we could do about it. Detecting a recursion at the same level, as in your example, is easy but detecting multi-level recursion is very hard. Also it would slow down the function very much and require lots of memory when it is used with multi level arrays. Maybe we can disallow array references or something like that. Patch is here: http://marcus-boerger.de/php/ext/bug29044.diff.txt please try. ------------------------------------------------------------------------ [2004-07-07 10:39:37] tomas_matousek at hotmail dot com Description: ------------ The compact() function crashes (terminates PHP process) if an array with infinite recursion is passed to it. Reproduce code: --------------- $a = array(&$a); compact($a); Expected result: ---------------- none Actual result: -------------- crash ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29044&edit=1