Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SplFileInfo::getFilename() segfault in combination with GlobIterator and no directory separator #12721

Closed
gafnex opened this issue Nov 18, 2023 · 1 comment

Comments

@gafnex
Copy link

gafnex commented Nov 18, 2023

Description

The following code:

<?php
$contents = '英文看不懂咋办?';
file_put_contents('file1.txt', $contents);
foreach (new GlobIterator('file1.txt') as $fileInfo) {
	echo $fileInfo->getFilename();
}

Resulted in this output:
segfault

But I expected this output instead:

file1.txt

PHP Version

PHP 8.2.12

Operating System

No response

@nielsdos
Copy link
Member

nielsdos commented Nov 18, 2023

File contents don't matter, this was broken in 7cd8879 and 9bae9ab. Fix coming very soon.

@nielsdos nielsdos changed the title SplFileInfo::getFilename() segfault in combination with GlobIterator and file containing Chinese letters SplFileInfo::getFilename() segfault in combination with GlobIterator and no directory separator Nov 18, 2023
nielsdos added a commit to nielsdos/php-src that referenced this issue Nov 18, 2023
…ith GlobIterator and no directory separator

This broke in 7cd8879 and 9bae9ab. NULL is a perfectly valid return
value that should be handled.
nielsdos added a commit that referenced this issue Nov 19, 2023
* PHP-8.2:
  Fix GH-12721: SplFileInfo::getFilename() segfault in combination with GlobIterator and no directory separator
nielsdos added a commit that referenced this issue Nov 19, 2023
* PHP-8.3:
  Fix GH-12721: SplFileInfo::getFilename() segfault in combination with GlobIterator and no directory separator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants