diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2018-08-22 15:38:02 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2018-08-22 15:38:30 +0200 |
commit | 36946f5c45328e81a6587980f444a56f9850d443 (patch) | |
tree | 4c8aadcdf02c2e69d9b4b0ef6c8c613baa37c8a4 | |
parent | 10661e28d1dbe24cfa6ca7859377fb2df61c6116 (diff) | |
parent | 32a728d351aab4bac28790697cd6820a8843645f (diff) | |
download | php-git-36946f5c45328e81a6587980f444a56f9850d443.tar.gz |
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
Fix #68825: Exception in DirectoryIterator::getLinkTarget()
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/spl/spl_directory.c | 3 | ||||
-rw-r--r-- | ext/spl/tests/bug68825.phpt | 25 |
3 files changed, 29 insertions, 0 deletions
@@ -40,6 +40,7 @@ PHP NEWS (Kevin Abel) - SPL: + . Fixed bug #68825 (Exception in DirectoryIterator::getLinkTarget()). (cmb) . Fixed bug #68175 (RegexIterator pregFlags are NULL instead of 0). (Tim Siebels) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 22d64fadc7..f411fca539 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1245,6 +1245,9 @@ SPL_METHOD(SplFileInfo, getLinkTarget) zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling); + if (intern->file_name == NULL) { + spl_filesystem_object_get_file_name(intern); + } #if defined(PHP_WIN32) || HAVE_SYMLINK if (intern->file_name == NULL) { php_error_docref(NULL, E_WARNING, "Empty filename"); diff --git a/ext/spl/tests/bug68825.phpt b/ext/spl/tests/bug68825.phpt new file mode 100644 index 0000000000..b1ed5fb60f --- /dev/null +++ b/ext/spl/tests/bug68825.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #68825 (Exception in DirectoryIterator::getLinkTarget()) +--FILE-- +<?php +$dir = __DIR__ . '/bug68825'; +mkdir($dir); +symlink(__FILE__, "$dir/foo"); + +$di = new \DirectoryIterator($dir); +foreach ($di as $entry) { + if ('foo' === $entry->getFilename()) { + var_dump($entry->getLinkTarget()); + } +} +?> +===DONE=== +--EXPECTF-- +string(%d) "%s%eext%espl%etests%ebug68825.php" +===DONE=== +--CLEAN-- +<?php +$dir = __DIR__ . '/bug68825'; +unlink("$dir/foo"); +rmdir($dir); +?> |