xref: /php-src/ext/spl/tests/gh17225.phpt (revision 4bfe69bb)
1--TEST--
2GH-17225 (NULL deref in spl_directory.c)
3--CREDITS--
4YuanchengJiang
5--EXTENSIONS--
6phar
7--INI--
8phar.readonly=0
9--FILE--
10<?php
11$fname = __DIR__ . '/gh17225.phar.zip';
12$phar = new Phar($fname);
13class HasDestructor {
14    public function __destruct() {
15        var_dump($GLOBALS['s']);
16    }
17}
18$s = new SplObjectStorage();
19$s[$phar] = new HasDestructor();
20register_shutdown_function(function() {
21    global $s;
22});
23var_dump($phar->isLink());
24?>
25--CLEAN--
26<?php
27@unlink(__DIR__ . '/gh17225.phar.zip');
28?>
29--EXPECTF--
30bool(false)
31object(SplObjectStorage)#%d (1) {
32  ["storage":"SplObjectStorage":private]=>
33  array(1) {
34    [0]=>
35    array(2) {
36      ["obj"]=>
37      object(Phar)#%d (4) {
38        ["pathName":"SplFileInfo":private]=>
39        string(0) ""
40        ["fileName":"SplFileInfo":private]=>
41        string(0) ""
42        ["glob":"DirectoryIterator":private]=>
43        bool(false)
44        ["subPathName":"RecursiveDirectoryIterator":private]=>
45        string(0) ""
46      }
47      ["inf"]=>
48      object(HasDestructor)#%d (0) {
49      }
50    }
51  }
52}
53