diff options
author | Xinchen Hui <laruence@php.net> | 2011-09-21 06:59:47 +0000 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2011-09-21 06:59:47 +0000 |
commit | c83594cd7a7b05cd903720e32ca3725e7d3b4666 (patch) | |
tree | 2fdcd6e9998849fd182697c467bd8305cfbab6f1 /sapi/cli/php_cli_server.c | |
parent | f3aa34a90d28155de7977708e184c4217701eea1 (diff) | |
download | php-git-c83594cd7a7b05cd903720e32ca3725e7d3b4666.tar.gz |
Remove double checking, and use MAXPATHLEN instead of a fixed length
Diffstat (limited to 'sapi/cli/php_cli_server.c')
-rw-r--r-- | sapi/cli/php_cli_server.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 5878f1e035..facb0b615a 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -1880,17 +1880,12 @@ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server } { zend_file_handle zfd; -#if HAVE_BROKEN_GETCWD - int old_cwd_fd = -1; - old_cwd_fd = open(".", 0); -#else char *old_cwd; + ALLOCA_FLAG(use_heap) -#define OLD_CWD_SIZE 4096 - old_cwd = do_alloca(OLD_CWD_SIZE, use_heap); + old_cwd = do_alloca(MAXPATHLEN, use_heap); old_cwd[0] = '\0'; - php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1)); -#endif + php_ignore_value(VCWD_GETCWD(old_cwd, MAXPATHLEN - 1)); zfd.type = ZEND_HANDLE_FILENAME; zfd.filename = server->router; @@ -1910,17 +1905,11 @@ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server } } zend_end_try(); -#if HAVE_BROKEN_GETCWD - if (old_cwd_fd != -1) { - fchdir(old_cwd_fd); - close(old_cwd_fd); - } -#else if (old_cwd[0] != '\0') { php_ignore_value(VCWD_CHDIR(old_cwd)); } + free_alloca(old_cwd, use_heap); -#endif } if (decline) { |