From: Arnaud Le Blanc Date: Mon, 11 Aug 2008 22:38:17 +0000 (+0000) Subject: Fixed #45181 (chdir() should clear relative entries in stat cache) X-Git-Tag: BEFORE_HEAD_NS_CHANGE~763 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0fa58b57750841c2f8cb7fba17d7f3af40592327;p=php Fixed #45181 (chdir() should clear relative entries in stat cache) --- diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 9b161ed35a..b555936b46 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 @@ -354,6 +355,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)