summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2003-05-13 02:26:42 +0000
committerSascha Schumann <sas@php.net>2003-05-13 02:26:42 +0000
commitaf402a9e136d6b343a0ebb2b8ab1734754341c9b (patch)
tree7d455415b3602b178f86e7cd6c13ceef23325844
parent56ba9b4ae51ef39eae376d0ca61c5dcea3eb016c (diff)
downloadphp-git-af402a9e136d6b343a0ebb2b8ab1734754341c9b.tar.gz
MFB don't close random fds
-rw-r--r--main/main.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/main/main.c b/main/main.c
index bd18864bbe..5c4a5c6f73 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1565,7 +1565,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
zend_file_handle *prepend_file_p, *append_file_p;
zend_file_handle prepend_file, append_file;
#if HAVE_BROKEN_GETCWD
- int old_cwd_fd;
+ int old_cwd_fd = -1;
#else
char *old_cwd;
#endif
@@ -1649,8 +1649,10 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
} zend_end_try();
#if HAVE_BROKEN_GETCWD
- fchdir(old_cwd_fd);
- close(old_cwd_fd);
+ if (old_cwd_fd != -1) {
+ fchdir(old_cwd_fd);
+ close(old_cwd_fd);
+ }
#else
if (old_cwd[0] != '\0') {
VCWD_CHDIR(old_cwd);