]> granicus.if.org Git - php/commitdiff
Fixed #45181 (chdir() should clear relative entries in stat cache)
authorArnaud Le Blanc <lbarnaud@php.net>
Mon, 11 Aug 2008 22:38:17 +0000 (22:38 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Mon, 11 Aug 2008 22:38:17 +0000 (22:38 +0000)
ext/standard/dir.c
ext/standard/tests/file/bug45181.phpt [new file with mode: 0644]

index 9b161ed35aa2c721a841672eb73dc66734b9af3d..b555936b460536d1db37aa0200cee753963d64ef 100644 (file)
@@ -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>
@@ -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 (file)
index 0000000..d64fa89
--- /dev/null
@@ -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)