xref: /PHP-8.1/Zend/tests/bug26698.phpt (revision f8d79582)
1--TEST--
2Bug #26698 (Thrown exceptions while evaluating argument to pass as parameter crash PHP)
3--FILE--
4<?php
5
6ini_set("report_memleaks", 0);  // the exception thrown in this test results in a memory leak, which is fine
7
8class ObjectOne
9{
10    function getNone()
11    {
12        throw new Exception('NONE');
13    }
14}
15
16class Proxy
17{
18    function three($a, $b, $c)
19    {
20    }
21
22    function callOne()
23    {
24        try
25        {
26            $res = new ObjectOne();
27            $this->three($res->getNone());
28        }
29        catch(Exception $e)
30        {
31            echo 'Caught: '.$e->getMessage()."\n";
32        }
33    }
34
35    function callTwo()
36    {
37        try
38        {
39            $res = new ObjectOne();
40            $this->three(1, $res->getNone());
41        }
42        catch(Exception $e)
43        {
44            echo 'Caught: '.$e->getMessage()."\n";
45        }
46    }
47
48    function callThree()
49    {
50        try
51        {
52            $res = new ObjectOne();
53            $this->three(1, 2, $res->getNone());
54        }
55        catch(Exception $e)
56        {
57            echo 'Caught: '.$e->getMessage()."\n";
58        }
59    }
60}
61
62$p = new Proxy();
63
64$p->callOne();
65$p->callTwo();
66$p->callThree();
67?>
68--EXPECT--
69Caught: NONE
70Caught: NONE
71Caught: NONE
72