From 0fa58b57750841c2f8cb7fba17d7f3af40592327 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Mon, 11 Aug 2008 22:38:17 +0000 Subject: [PATCH] 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 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) -- 2.40.0