xref: /PHP-8.0/Zend/tests/bug63762.phpt (revision 6fd13d0a)
1--TEST--
2Bug #63762 - Sigsegv when Exception::$trace is changed by user
3--FILE--
4<?php
5$e = new Exception();
6
7$ref = new ReflectionProperty($e, 'trace');
8$ref->setAccessible(TRUE);
9
10echo "Array of NULL:\n";
11$ref->setValue($e, array(NULL));
12
13var_dump($e->getTraceAsString());
14
15echo "\nArray of empty array:\n";
16$ref->setValue($e, array(array()));
17var_dump($e->getTraceAsString());
18
19echo "\nArray of array of NULL values:\n";
20$ref->setValue($e, array(array(
21    'file'  => NULL,
22    'line'  => NULL,
23    'class' => NULL,
24    'type'  => NULL,
25    'function' => NULL,
26    'args'  => NULL
27)));
28var_dump($e->getTraceAsString());
29?>
30--EXPECTF--
31Array of NULL:
32
33Warning: Expected array for frame 0 in %s on line %d
34string(9) "#0 {main}"
35
36Array of empty array:
37string(36) "#0 [internal function]: ()
38#1 {main}"
39
40Array of array of NULL values:
41
42Warning: File name is not a string in %s on line %d
43
44Warning: Value for class is not a string in %s on line %d
45
46Warning: Value for type is not a string in %s on line %d
47
48Warning: Value for function is not a string in %s on line %d
49
50Warning: args element is not an array in %s on line %d
51string(58) "#0 [unknown file]: [unknown][unknown][unknown]()
52#1 {main}"
53