From a1311b8bc2f0853258ef910f931027ccd28e8f9f Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Mon, 11 Aug 2008 22:39:42 +0000 Subject: [PATCH] MFH: Fixed #45181 (chdir() should clear relative entries in stat cache) --- ext/standard/dir.c | 10 ++++++++++ ext/standard/tests/file/bug45181.phpt | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 ext/standard/tests/file/bug45181.phpt 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) -- 2.50.1