diff options
author | Anatol Belski <ab@php.net> | 2013-10-29 17:15:40 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2013-10-29 17:15:40 +0100 |
commit | e17de5e9fd1f25626a6f8bf71a1ad882ac567fa6 (patch) | |
tree | 33e7b544b4a7bc6a6eaf5b863973b576cb8a73eb /main | |
parent | c86862cb3cd74cde1233630bbc7b97e276d68d28 (diff) | |
parent | 25dc4af3920d40c4dbec203485c15922a29e08c3 (diff) | |
download | php-git-e17de5e9fd1f25626a6f8bf71a1ad882ac567fa6.tar.gz |
Merge branch 'bug50333' of github.com:weltling/php-src into bug50333
Diffstat (limited to 'main')
-rw-r--r-- | main/SAPI.c | 4 | ||||
-rw-r--r-- | main/fopen_wrappers.c | 6 | ||||
-rw-r--r-- | main/main.c | 16 | ||||
-rw-r--r-- | main/php.h | 2 | ||||
-rw-r--r-- | main/php_open_temporary_file.c | 10 | ||||
-rw-r--r-- | main/streams/plain_wrapper.c | 2 |
6 files changed, 18 insertions, 22 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index 8ee7649648..c9ba5d5dce 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -91,8 +91,6 @@ SAPI_API void sapi_startup(sapi_module_struct *sf) sapi_globals_ctor(&sapi_globals); #endif - virtual_cwd_startup(); /* Could use shutdown to free the main cwd but it would just slow it down for CGI */ - #ifdef PHP_WIN32 tsrm_win32_startup(); #endif @@ -110,8 +108,6 @@ SAPI_API void sapi_shutdown(void) reentrancy_shutdown(); - virtual_cwd_shutdown(); - #ifdef PHP_WIN32 tsrm_win32_shutdown(); #endif diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 1d99a4e20e..6722798598 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -791,11 +791,11 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co } } - new_state.cwd = strdup(cwd); + new_state.cwd = estrdup(cwd); new_state.cwd_length = strlen(cwd); if (virtual_file_ex(&new_state, filepath, NULL, realpath_mode TSRMLS_CC)) { - free(new_state.cwd); + efree(new_state.cwd); return NULL; } @@ -806,7 +806,7 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co } else { real_path = estrndup(new_state.cwd, new_state.cwd_length); } - free(new_state.cwd); + efree(new_state.cwd); return real_path; } diff --git a/main/main.c b/main/main.c index 1cc842b212..2d018a7467 100644 --- a/main/main.c +++ b/main/main.c @@ -1816,6 +1816,9 @@ void php_request_shutdown(void *dummy) sapi_deactivate(TSRMLS_C); } zend_end_try(); + /* 9.5 free virtual CWD memory */ + virtual_cwd_deactivate(TSRMLS_C); + /* 10. Destroy stream hashes */ zend_try { php_shutdown_stream_hashes(TSRMLS_C); @@ -2243,9 +2246,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod } #endif -#ifdef ZTS zend_post_startup(TSRMLS_C); -#endif module_initialized = 1; @@ -2315,6 +2316,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod shutdown_memory_manager(1, 0 TSRMLS_CC); zend_interned_strings_snapshot(TSRMLS_C); + virtual_cwd_activate(TSRMLS_C); /* we're done */ return retval; @@ -2410,14 +2412,13 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) volatile int old_cwd_fd = -1; #else char *old_cwd; - ALLOCA_FLAG(use_heap) #endif int retval = 0; EG(exit_status) = 0; #ifndef HAVE_BROKEN_GETCWD # define OLD_CWD_SIZE 4096 - old_cwd = do_alloca(OLD_CWD_SIZE, use_heap); + old_cwd = emalloc(OLD_CWD_SIZE); old_cwd[0] = '\0'; #endif @@ -2498,7 +2499,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) if (old_cwd[0] != '\0') { php_ignore_value(VCWD_CHDIR(old_cwd)); } - free_alloca(old_cwd, use_heap); + efree(old_cwd); #endif return retval; } @@ -2509,11 +2510,10 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval **ret TSRMLS_DC) { char *old_cwd; - ALLOCA_FLAG(use_heap) EG(exit_status) = 0; #define OLD_CWD_SIZE 4096 - old_cwd = do_alloca(OLD_CWD_SIZE, use_heap); + old_cwd = emalloc(OLD_CWD_SIZE); old_cwd[0] = '\0'; zend_try { @@ -2536,7 +2536,7 @@ PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval **ret php_ignore_value(VCWD_CHDIR(old_cwd)); } - free_alloca(old_cwd, use_heap); + efree(old_cwd); return EG(exit_status); } /* }}} */ diff --git a/main/php.h b/main/php.h index 17ac8b4fd2..f9c6f2030c 100644 --- a/main/php.h +++ b/main/php.h @@ -400,7 +400,7 @@ END_EXTERN_C() /* Virtual current working directory support */ -#include "tsrm_virtual_cwd.h" +#include "zend_virtual_cwd.h" #include "zend_constants.h" diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index 054d497be6..8315297738 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -124,11 +124,11 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** cwd[0] = '\0'; } - new_state.cwd = strdup(cwd); + new_state.cwd = estrdup(cwd); new_state.cwd_length = strlen(cwd); if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) { - free(new_state.cwd); + efree(new_state.cwd); return -1; } @@ -140,7 +140,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** if (spprintf(&opened_path, 0, "%s%s%sXXXXXX", new_state.cwd, trailing_slash, pfx) >= MAXPATHLEN) { efree(opened_path); - free(new_state.cwd); + efree(new_state.cwd); return -1; } @@ -151,7 +151,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** * which means that opening it will fail... */ if (VCWD_CHMOD(opened_path, 0600)) { efree(opened_path); - free(new_state.cwd); + efree(new_state.cwd); return -1; } fd = VCWD_OPEN_MODE(opened_path, open_flags, 0600); @@ -170,7 +170,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** } else { *opened_path_p = opened_path; } - free(new_state.cwd); + efree(new_state.cwd); return fd; } /* }}} */ diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 949b827679..4dbf6889d7 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1436,7 +1436,7 @@ not_relative_path: php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", cwd, filename, MAXPATHLEN); } - free(cwd); + efree(cwd); if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(trypath TSRMLS_CC)) { return NULL; |