]> granicus.if.org Git - php/commitdiff
MFH: fix segfault & improve test
authorHannes Magnusson <bjori@php.net>
Mon, 6 Nov 2006 15:21:45 +0000 (15:21 +0000)
committerHannes Magnusson <bjori@php.net>
Mon, 6 Nov 2006 15:21:45 +0000 (15:21 +0000)
ext/spl/spl_directory.c
ext/spl/tests/fileobject_003.phpt

index ff4d788a0e63c1305add8b9c1e6689cb1e6f16e2..39b2c5827a9224bb24ac149ab29b9c86d7001d3b 100755 (executable)
@@ -406,6 +406,8 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil
                } else {
                        intern->file_name = source->file_name;
                        intern->file_name_len = source->file_name_len;
+                       intern->path = estrndup(source->path, source->path_len);
+                       intern->path_len = source->path_len;
                
                        intern->u.file.open_mode = "r";
                        intern->u.file.open_mode_len = 1;
index 74f2002d00d3d858397a6f86208568826f88eb32..02bc6c8fea703f488b6c54c447cf38f7b9badd75 100755 (executable)
@@ -31,6 +31,9 @@ function test($name, $lc, $lp)
        var_dump($f->getPath());
        $l = substr($f->getPath(), -1);
        var_dump($l != '/' && $l != '\\' && $l == $lp);
+
+       $fo = $o->openFile();
+       var_dump($fo->getPathName(), $fo->getFileName(), $fo->getPath());
 }
 
 test(dirname(__FILE__) . '/' . 'fileobject_001a.txt', 't', substr(dirname(__FILE__),-1));
@@ -56,6 +59,9 @@ string(%d) "%sfileobject_001a.txt"
 bool(true)
 string(%d) "%stests"
 bool(true)
+string(%d) "%sfileobject_001a.txt"
+string(%d) "%sfileobject_001a.txt"
+string(%d) "%stests"
 ===1===
 object(SplFileInfo)#%d (0) {
 }
@@ -71,6 +77,9 @@ string(%d) "%stests"
 bool(true)
 string(%d) "%sspl"
 bool(true)
+string(%d) "%stests"
+string(%d) "%stests"
+string(%d) "%stests"
 ===2===
 object(SplFileInfo)#1 (0) {
 }
@@ -86,4 +95,7 @@ string(%d) "%stests"
 bool(true)
 string(%d) "%sspl"
 bool(true)
+string(%d) "%stests"
+string(%d) "%stests"
+string(%d) "%sspl"
 ===DONE===