xref: /php-src/ext/spl/tests/bug73423.phpt (revision b3e08881)
1--TEST--
2Bug #73423 (Reproducible crash with GDB backtrace)
3--FILE--
4<?php
5
6class foo implements \RecursiveIterator
7  {
8    public $foo = [];
9
10    public Function current(): mixed
11      {
12        return current ($this->foo);
13      }
14
15    public Function key(): mixed
16      {
17        return key ($this->foo);
18      }
19
20    public Function next(): void
21      {
22        next ($this->foo);
23      }
24
25    public Function rewind(): void
26      {
27        reset ($this->foo);
28      }
29
30    public Function valid(): bool
31      {
32        return current ($this->foo) !== false;
33      }
34
35    public Function getChildren(): ?RecursiveIterator
36      {
37        return current ($this->foo);
38      }
39
40    public Function hasChildren(): bool
41      {
42        return (bool) count($this->foo);
43      }
44  }
45
46
47class fooIterator extends \RecursiveFilterIterator
48  {
49    public Function __destruct ()
50      {
51        eval("class A extends NotExists {}");
52
53        /* CRASH */
54      }
55
56    public Function accept(): bool
57      {
58        return true;
59      }
60  }
61
62
63$foo = new foo ();
64
65$foo->foo[] = new foo ();
66
67foreach (new \RecursiveIteratorIterator (new fooIterator ($foo)) as $bar) ;
68
69?>
70--EXPECTF--
71Fatal error: Uncaught Error: Class "NotExists" not found in %s:%d
72Stack trace:
73#0 %s(%d): eval()
74#1 %s(%d): fooIterator->__destruct()
75#2 {main}
76
77Next Error: Class "NotExists" not found in %s:%d
78Stack trace:
79#0 %s(%d): eval()
80#1 %s(%d): fooIterator->__destruct()
81#2 {main}
82  thrown in %s on line %d
83