xref: /php-src/ext/spl/tests/gh15833_2.phpt (revision b666dc97)
1--TEST--
2GH-15833 (Segmentation fault (access null pointer) in ext/spl/spl_array.c)
3--CREDITS--
4YuanchengJiang
5--FILE--
6<?php
7class C {
8    public int $a = 1;
9}
10$reflector = new ReflectionClass(C::class);
11$obj = $reflector->newLazyProxy(function ($obj) {
12    static $counter = 0;
13    throw new Error('nope ' . ($counter++));
14});
15$recursiveArrayIterator = new RecursiveArrayIterator($obj);
16try {
17    var_dump($recursiveArrayIterator->current());
18} catch (Error $e) {
19    echo $e->getMessage(), "\n";
20}
21try {
22    var_dump($recursiveArrayIterator->current());
23} catch (Error $e) {
24    echo $e->getMessage(), "\n";
25}
26try {
27    $recursiveArrayIterator->next();
28} catch (Error $e) {
29    echo $e->getMessage(), "\n";
30}
31try {
32    var_dump($recursiveArrayIterator->current());
33} catch (Error $e) {
34    echo $e->getMessage(), "\n";
35}
36?>
37--EXPECT--
38nope 0
39nope 1
40nope 2
41nope 3
42