diff options
| author | Arnaud Le Blanc <lbarnaud@php.net> | 2008-08-11 22:39:42 +0000 |
|---|---|---|
| committer | Arnaud Le Blanc <lbarnaud@php.net> | 2008-08-11 22:39:42 +0000 |
| commit | a1311b8bc2f0853258ef910f931027ccd28e8f9f (patch) | |
| tree | c568627a40b7c4f3a8df524ba7889158c8cc8ee2 | |
| parent | b9ab70c0d24ee9da0db69fe306c16af113f1f7aa (diff) | |
| download | php-git-a1311b8bc2f0853258ef910f931027ccd28e8f9f.tar.gz | |
MFH: Fixed #45181 (chdir() should clear relative entries in stat cache)
| -rw-r--r-- | ext/standard/dir.c | 10 | ||||
| -rw-r--r-- | ext/standard/tests/file/bug45181.phpt | 16 |
2 files changed, 26 insertions, 0 deletions
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 <dirent.h> @@ -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-- +<?php +mkdir("bug45181_x"); +var_dump(is_dir("bug45181_x")); +chdir("bug45181_x"); +var_dump(is_dir("bug45181_x")); +?> +--CLEAN-- +<?php +rmdir("bug45181_x"); +?> +--EXPECT-- +bool(true) +bool(false) |
