]> granicus.if.org Git - php/commitdiff
MFB don't close random fds
authorSascha Schumann <sas@php.net>
Tue, 13 May 2003 02:26:42 +0000 (02:26 +0000)
committerSascha Schumann <sas@php.net>
Tue, 13 May 2003 02:26:42 +0000 (02:26 +0000)
main/main.c

index bd18864bbe246c814715a75b5079813900302de9..5c4a5c6f7308a67c32d2a5de9d44d43fb1f48bad 100644 (file)
@@ -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);