xref: /PHP-8.2/Zend/tests/bug70083.phpt (revision f8d79582)
1--TEST--
2Bug #70083 (Use after free with assign by ref to overloaded objects)
3--FILE--
4<?php
5
6class foo {
7    private $var;
8    function __get($e) {
9        return $this;
10    }
11}
12
13function &noref() { $foo = 1; return $foo; }
14
15$foo = new foo;
16try {
17    $foo->i = &noref();
18} catch (Error $e) {
19    echo $e->getMessage(), "\n";
20}
21var_dump($foo);
22
23?>
24--EXPECT--
25Cannot assign by reference to overloaded object
26object(foo)#1 (1) {
27  ["var":"foo":private]=>
28  NULL
29}
30