Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,22 @@ static inline void spl_filesystem_object_get_file_name(spl_filesystem_object *in
}
break;
case SPL_FS_DIR:
if (intern->file_name) {
efree(intern->file_name);
{
size_t path_len = 0;
char *path = spl_filesystem_object_get_path(intern, &path_len);
if (intern->file_name) {
efree(intern->file_name);
}
/* if there is parent path, ammend it, otherwise just use the given path as is */
if(path_len==0 && php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)){
intern->file_name_len = spprintf(&intern->file_name, 0, "%s",
intern->u.dir.entry.d_name);
} else{
intern->file_name_len = spprintf(&intern->file_name, 0, "%s%c%s",
path,
slash, intern->u.dir.entry.d_name);
}
}
intern->file_name_len = spprintf(&intern->file_name, 0, "%s%c%s",
spl_filesystem_object_get_path(intern, NULL),
slash, intern->u.dir.entry.d_name);
break;
}
} /* }}} */
Expand Down
18 changes: 18 additions & 0 deletions ext/spl/tests/bug51068.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
SPL: glob wrapper interactions with DirectoryIterator
--FILE--
<?php
touch('bug.51068');
$iter = new DirectoryIterator('glob://*.51068');
foreach ($iter as $f) {
var_dump($f->getFilename());
var_dump($f->getSize());
}
?>
--CLEAN--
<?php
unlink('bug.51068');
?>
--EXPECT--
string(9) "bug.51068"
int(0)
2 changes: 1 addition & 1 deletion main/streams/glob_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static void php_glob_stream_path_split(glob_s_t *pglob, const char *path, int ge
if (pglob->path) {
efree(pglob->path);
}
if (path != gpath) {
if ((path - gpath) > 1) {
path--;
}
pglob->path_len = path - gpath;
Expand Down