xref: /PHP-8.0/ext/json/tests/bug62369.phpt (revision 7aacc705)
1--TEST--
2FR #62369 (Segfault on json_encode(deeply_nested_array)
3--FILE--
4<?php
5
6$array = array();
7for ($i=0; $i < 550; $i++) {
8    $array = array($array);
9}
10
11json_encode($array, 0, 551);
12switch (json_last_error()) {
13    case JSON_ERROR_NONE:
14        echo 'OK' . PHP_EOL;
15    break;
16    case JSON_ERROR_DEPTH:
17        echo 'ERROR' . PHP_EOL;
18    break;
19}
20
21json_encode($array, 0, 540);
22switch (json_last_error()) {
23    case JSON_ERROR_NONE:
24        echo 'OK' . PHP_EOL;
25    break;
26    case JSON_ERROR_DEPTH:
27        echo 'ERROR' . PHP_EOL;
28    break;
29}
30?>
31--EXPECT--
32OK
33ERROR
34