]> granicus.if.org Git - php/commitdiff
MFH
authorMarcus Boerger <helly@php.net>
Sat, 30 Oct 2004 14:35:01 +0000 (14:35 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 30 Oct 2004 14:35:01 +0000 (14:35 +0000)
ext/spl/spl_directory.c

index 11c09a26be52f1e9562b55e7da53f93ca9d2995e..3cbd2cacc930731a8d3c69e8c192c534d9f35479 100755 (executable)
@@ -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) {