From: Hannes Magnusson Date: Mon, 6 Nov 2006 15:20:23 +0000 (+0000) Subject: Fix segfault on $splinfo->openFile()->getPath() X-Git-Tag: RELEASE_1_0_0RC1~1120 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d8895dd81d375e83c61a236e6d3b1a61a6e62709;p=php Fix segfault on $splinfo->openFile()->getPath() Improve test --- diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 9aac17aacd..210edc595f 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -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; diff --git a/ext/spl/tests/fileobject_003.phpt b/ext/spl/tests/fileobject_003.phpt index 2624ff67a7..8bdb603635 100755 --- a/ext/spl/tests/fileobject_003.phpt +++ b/ext/spl/tests/fileobject_003.phpt @@ -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===