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