]> granicus.if.org Git - php/commitdiff
Fix segfault on $splinfo->openFile()->getPath()
authorHannes Magnusson <bjori@php.net>
Mon, 6 Nov 2006 15:20:23 +0000 (15:20 +0000)
committerHannes Magnusson <bjori@php.net>
Mon, 6 Nov 2006 15:20:23 +0000 (15:20 +0000)
Improve test

ext/spl/spl_directory.c
ext/spl/tests/fileobject_003.phpt

index 9aac17aacd00805a57981b5dcf22c32cdc976510..210edc595fa49e9b333f98c08fbc836f769a1693 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 2624ff67a7aa2b5881738435640d8af406ce2425..8bdb6036359a7ba0f159fd06a033ba7d9ca107d0 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===