mirror of
https://github.com/php/php-src.git
synced 2024-12-20 07:20:33 +08:00
e81751ceac
We need to make sure that the function is fully compiled before we calculate the stack size. There already was a check for directly recursive calls, but the same issue exists with indirectly recursive calls. I'm using DONE_PASS_TWO as the indication that the function is fully compiled.
32 lines
747 B
PHP
32 lines
747 B
PHP
--TEST--
|
|
Bug #78502: Incorrect stack size calculation for indirectly recursive function call
|
|
--FILE--
|
|
<?php
|
|
|
|
$tree = [
|
|
'name' => 'a',
|
|
'quant' => 1,
|
|
'children' => [
|
|
['name' => 'b', 'quant' => 1],
|
|
['name' => 'c', 'quant' => 1, 'children' => [
|
|
['name' => 'd', 'quant' => 1],
|
|
]],
|
|
],
|
|
];
|
|
|
|
function tree_map($tree, $recursive_attr, closure $callback){
|
|
if(isset($tree[$recursive_attr])){
|
|
$tree[$recursive_attr] = array_map(function($c) use($recursive_attr, $callback){
|
|
return tree_map($c, $recursive_attr, $callback);
|
|
}, $tree[$recursive_attr]);
|
|
}
|
|
return $callback($tree);
|
|
}
|
|
|
|
tree_map($tree, 'children', function ($node) {});
|
|
|
|
?>
|
|
===DONE===
|
|
--EXPECT--
|
|
===DONE===
|