From 7226e7077d08b7e03f61fdab716547fec0bd42ed Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sat, 30 Oct 2004 14:35:01 +0000 Subject: [PATCH] MFH --- ext/spl/spl_directory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 11c09a26be..3cbd2cacc9 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -120,9 +120,15 @@ static zend_object_value spl_ce_dir_object_new(zend_class_entry *class_type TSRM /* open a directory resource */ static void spl_ce_dir_open(spl_ce_dir_object* intern, char *path TSRMLS_DC) { + int path_len = strlen(path); + intern->dirp = php_stream_opendir(path, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); - intern->path = estrdup(path); + if (path_len && (path[path_len-1] == '/' || path[path_len-1] == '\\')) { + intern->path = estrndup(path, --path_len); + } else { + intern->path = estrndup(path, path_len); + } intern->index = 0; if (intern->dirp == NULL) { -- 2.40.0