From: Arnaud Le Blanc Date: Mon, 11 Aug 2008 22:39:42 +0000 (+0000) Subject: MFH: Fixed #45181 (chdir() should clear relative entries in stat cache) X-Git-Tag: php-5.2.7RC1~123 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1311b8bc2f0853258ef910f931027ccd28e8f9f;p=php MFH: Fixed #45181 (chdir() should clear relative entries in stat cache) --- diff --git a/ext/standard/dir.c b/ext/standard/dir.c index c8f1ae731b..ad0f5037cb 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -26,6 +26,7 @@ #include "php_dir.h" #include "php_string.h" #include "php_scandir.h" +#include "basic_functions.h" #ifdef HAVE_DIRENT_H #include @@ -329,6 +330,15 @@ PHP_FUNCTION(chdir) RETURN_FALSE; } + if (BG(CurrentStatFile) && !IS_ABSOLUTE_PATH(BG(CurrentStatFile), strlen(BG(CurrentStatFile)))) { + efree(BG(CurrentStatFile)); + BG(CurrentStatFile) = NULL; + } + if (BG(CurrentLStatFile) && !IS_ABSOLUTE_PATH(BG(CurrentLStatFile), strlen(BG(CurrentLStatFile)))) { + efree(BG(CurrentLStatFile)); + BG(CurrentLStatFile) = NULL; + } + RETURN_TRUE; } /* }}} */ diff --git a/ext/standard/tests/file/bug45181.phpt b/ext/standard/tests/file/bug45181.phpt new file mode 100644 index 0000000000..d64fa89937 --- /dev/null +++ b/ext/standard/tests/file/bug45181.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #45181 (chdir() should clear relative entries in stat cache) +--FILE-- + +--CLEAN-- + +--EXPECT-- +bool(true) +bool(false)