xref: /PHP-8.3/ext/standard/tests/array/bug43495.phpt (revision 5fbd49f9)
1--TEST--
2Bug #43495 (array_merge_recursive() crashes with recursive arrays)
3--FILE--
4<?php
5$a=array("key1"=>array("key2"=>array()));
6$a["key1"]["key2"]["key3"]=&$a;
7
8$b=array("key1"=>array("key2"=>array()));
9$b["key1"]["key2"]["key3"]=&$b;
10
11
12try {
13    array_merge_recursive($a,$b);
14} catch (\Error $e) {
15    echo $e->getMessage() . "\n";
16}
17
18/* Break recursion */
19$a["key1"]["key2"]["key3"] = null;
20$b["key1"]["key2"]["key3"] = null;
21
22?>
23--EXPECT--
24Recursion detected
25