xref: /php-src/ext/spl/tests/gh12721.phpt (revision 4d41dffb)
1--TEST--
2GH-12721 (SplFileInfo::getFilename() segfault in combination with GlobIterator and no directory separator)
3--FILE--
4<?php
5
6file_put_contents('file1.gh12721', 'hello');
7
8echo "--- No slash ---\n";
9
10foreach (new GlobIterator('*.gh12721') as $fileInfo) {
11	echo $fileInfo->getFilename(), "\n";
12	echo $fileInfo->getExtension(), "\n";
13	echo $fileInfo->getBasename(), "\n";
14	var_dump($fileInfo->getFileInfo());
15}
16
17echo "--- With slash ---\n";
18
19foreach (new GlobIterator('./*.gh12721') as $fileInfo) {
20	echo $fileInfo->getFilename(), "\n";
21	echo $fileInfo->getExtension(), "\n";
22	echo $fileInfo->getBasename(), "\n";
23	var_dump($fileInfo->getFileInfo());
24}
25
26?>
27--CLEAN--
28<?php
29@unlink('file1.gh12721');
30?>
31--EXPECTF--
32--- No slash ---
33file1.gh12721
34gh12721
35file1.gh12721
36object(SplFileInfo)#4 (2) {
37  ["pathName":"SplFileInfo":private]=>
38  string(13) "file1.gh12721"
39  ["fileName":"SplFileInfo":private]=>
40  string(13) "file1.gh12721"
41}
42--- With slash ---
43file1.gh12721
44gh12721
45file1.gh12721
46object(SplFileInfo)#3 (2) {
47  ["pathName":"SplFileInfo":private]=>
48  string(15) "%sfile1.gh12721"
49  ["fileName":"SplFileInfo":private]=>
50  string(13) "file1.gh12721"
51}
52