diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-03-04 02:05:28 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-03-04 02:05:28 +0300 |
commit | 2fa8d67a5ce59ba9ba6192481e3c2522c3ff5542 (patch) | |
tree | 9d9d57215f756c387722e74d7d1e1c2de3276a1c /ext | |
parent | 2841aa95db84f3563c94c90f84bf7f47ba159a2d (diff) | |
download | php-git-2fa8d67a5ce59ba9ba6192481e3c2522c3ff5542.tar.gz |
Use zend_string* instead of char* for opened_patch handling. Avoid reallocations and improve string reuse.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bz2/bz2.c | 18 | ||||
-rw-r--r-- | ext/bz2/php_bz2.h | 2 | ||||
-rw-r--r-- | ext/dba/dba.c | 22 | ||||
-rw-r--r-- | ext/gd/gd.c | 6 | ||||
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 75 | ||||
-rw-r--r-- | ext/opcache/zend_accelerator_module.c | 19 | ||||
-rw-r--r-- | ext/phar/dirstream.c | 2 | ||||
-rw-r--r-- | ext/phar/dirstream.h | 2 | ||||
-rw-r--r-- | ext/phar/func_interceptors.c | 33 | ||||
-rw-r--r-- | ext/phar/phar.c | 37 | ||||
-rw-r--r-- | ext/phar/phar_internal.h | 4 | ||||
-rw-r--r-- | ext/phar/phar_object.c | 19 | ||||
-rw-r--r-- | ext/phar/stream.c | 10 | ||||
-rw-r--r-- | ext/phar/stream.h | 2 | ||||
-rw-r--r-- | ext/phar/util.c | 17 | ||||
-rw-r--r-- | ext/spl/php_spl.c | 4 | ||||
-rw-r--r-- | ext/standard/file.c | 6 | ||||
-rw-r--r-- | ext/standard/ftp_fopen_wrapper.c | 6 | ||||
-rw-r--r-- | ext/standard/http_fopen_wrapper.c | 4 | ||||
-rw-r--r-- | ext/standard/php_fopen_wrapper.c | 3 | ||||
-rw-r--r-- | ext/standard/php_fopen_wrappers.h | 4 | ||||
-rw-r--r-- | ext/standard/streamsfuncs.c | 8 | ||||
-rw-r--r-- | ext/zip/php_zip.h | 2 | ||||
-rw-r--r-- | ext/zip/zip_stream.c | 4 | ||||
-rw-r--r-- | ext/zlib/php_zlib.h | 2 | ||||
-rw-r--r-- | ext/zlib/zlib_fopen_wrapper.c | 2 |
26 files changed, 152 insertions, 161 deletions
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index 9b59942f26..969c5e131c 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -235,7 +235,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, - char **opened_path, + zend_string **opened_path, php_stream_context *context STREAMS_DC) { php_stream *retstream = NULL, *stream = NULL; @@ -266,20 +266,8 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, bz_file = BZ2_bzopen(path_copy, mode); if (opened_path && bz_file) { -#ifdef VIRTUAL_DIR - *opened_path = path_copy; - path_copy = NULL; -#else - *opened_path = estrdup(path_copy); -#endif - } - -#ifdef VIRTUAL_DIR - if (path_copy) { - efree(path_copy); + *opened_path = zend_string_init(path_copy, strlen(path_copy), 0); } -#endif - path_copy = NULL; if (bz_file == NULL) { /* that didn't work, so try and get something from the network/wrapper */ @@ -296,7 +284,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, * failed. */ if (opened_path && !bz_file && mode[0] == 'w') { - VCWD_UNLINK(*opened_path); + VCWD_UNLINK((*opened_path)->val); } } diff --git a/ext/bz2/php_bz2.h b/ext/bz2/php_bz2.h index b3c0725086..b1aa4ca97c 100644 --- a/ext/bz2/php_bz2.h +++ b/ext/bz2/php_bz2.h @@ -47,7 +47,7 @@ extern zend_module_entry bz2_module_entry; # define PHP_BZ2_API #endif -PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC); +PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, const char *mode, php_stream *innerstream STREAMS_DC); #define php_stream_bz2open_from_BZFILE(bz, mode, innerstream) _php_stream_bz2open_from_BZFILE((bz), (mode), (innerstream) STREAMS_CC) diff --git a/ext/dba/dba.c b/ext/dba/dba.c index f4569071f1..8491ff6a38 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -627,7 +627,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) char *file_mode; char mode[4], *pmode, *lock_file_mode = NULL; int persistent_flag = persistent ? STREAM_OPEN_PERSISTENT : 0; - char *opened_path = NULL; + zend_string *opened_path = NULL; char *lock_name; if (ac < 2) { @@ -853,13 +853,9 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) /* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */ lock_file_mode = "a+b"; } else { - if (!persistent) { - info->lock.name = opened_path; - } else { - if (opened_path) { - info->lock.name = pestrdup(opened_path, persistent); - efree(opened_path); - } + if (opened_path) { + info->lock.name = pestrndup(opened_path->val, opened_path->len, persistent); + zend_string_release(opened_path); } } } @@ -869,15 +865,11 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) if (lock_dbf) { /* replace the path info with the real path of the opened file */ pefree(info->path, persistent); - info->path = pestrdup(opened_path, persistent); + info->path = pestrndup(opened_path->val, opened_path->len, persistent); } /* now store the name of the lock */ - if (!persistent) { - info->lock.name = opened_path; - } else { - info->lock.name = pestrdup(opened_path, persistent); - efree(opened_path); - } + info->lock.name = pestrdup(opened_path->val, opened_path->len, persistent); + zend_string_release(opened_path); } } if (!lock_dbf) { diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 61050ba288..9c252f45fc 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2686,7 +2686,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char int b; FILE *tmp; char buf[4096]; - char *path; + zend_string *path; tmp = php_open_temporary_file(NULL, NULL, &path); if (tmp == NULL) { @@ -2745,8 +2745,8 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char } fclose(tmp); - VCWD_UNLINK((const char *)path); /* make sure that the temporary file is removed */ - efree(path); + VCWD_UNLINK((const char *)path->val); /* make sure that the temporary file is removed */ + zend_string_release(path); } RETURN_TRUE; } diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 584a12dc42..efd0be4c8c 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -105,7 +105,7 @@ char *zps_api_failure_reason = NULL; static zend_op_array *(*accelerator_orig_compile_file)(zend_file_handle *file_handle, int type); static int (*accelerator_orig_zend_stream_open_function)(const char *filename, zend_file_handle *handle ); -static char *(*accelerator_orig_zend_resolve_path)(const char *filename, int filename_len); +static zend_string *(*accelerator_orig_zend_resolve_path)(const char *filename, int filename_len); static void (*orig_chdir)(INTERNAL_FUNCTION_PARAMETERS) = NULL; static ZEND_INI_MH((*orig_include_path_on_modify)) = NULL; @@ -765,25 +765,23 @@ static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle break; case ZEND_HANDLE_FILENAME: case ZEND_HANDLE_MAPPED: - { - char *file_path = file_handle->opened_path; + if (file_handle->opened_path) { + char *file_path = file_handle->opened_path->val; - if (file_path) { - if (is_stream_path(file_path)) { - if (zend_get_stream_timestamp(file_path, &statbuf) == SUCCESS) { - break; - } - } - if (VCWD_STAT(file_path, &statbuf) != -1) { + if (is_stream_path(file_path)) { + if (zend_get_stream_timestamp(file_path, &statbuf) == SUCCESS) { break; } } - - if (zend_get_stream_timestamp(file_handle->filename, &statbuf) != SUCCESS) { - return 0; + if (VCWD_STAT(file_path, &statbuf) != -1) { + break; } - break; } + + if (zend_get_stream_timestamp(file_handle->filename, &statbuf) != SUCCESS) { + return 0; + } + break; case ZEND_HANDLE_STREAM: { php_stream *stream = (php_stream *)file_handle->handle.stream.handle; @@ -825,20 +823,25 @@ static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle static inline int do_validate_timestamps(zend_persistent_script *persistent_script, zend_file_handle *file_handle) { zend_file_handle ps_handle; - char *full_path_ptr = NULL; + zend_string *full_path_ptr = NULL; /** check that the persistent script is indeed the same file we cached * (if part of the path is a symlink than it possible that the user will change it) * See bug #15140 */ if (file_handle->opened_path) { - if (strcmp(persistent_script->full_path->val, file_handle->opened_path) != 0) { + if (persistent_script->full_path != file_handle->opened_path && + (persistent_script->full_path->len != file_handle->opened_path->len || + memcmp(persistent_script->full_path->val, file_handle->opened_path->val, file_handle->opened_path->len) != 0)) { return FAILURE; } } else { full_path_ptr = accelerator_orig_zend_resolve_path(file_handle->filename, strlen(file_handle->filename)); - if (full_path_ptr && strcmp(persistent_script->full_path->val, full_path_ptr) != 0) { - efree(full_path_ptr); + if (full_path_ptr && + persistent_script->full_path != full_path_ptr && + (persistent_script->full_path->len != full_path_ptr->len || + memcmp(persistent_script->full_path->val, full_path_ptr->val, full_path_ptr->len) != 0)) { + zend_string_release(full_path_ptr); return FAILURE; } file_handle->opened_path = full_path_ptr; @@ -846,7 +849,7 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri if (persistent_script->timestamp == 0) { if (full_path_ptr) { - efree(full_path_ptr); + zend_string_release(full_path_ptr); file_handle->opened_path = NULL; } return FAILURE; @@ -854,19 +857,19 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri if (zend_get_file_handle_timestamp(file_handle, NULL) == persistent_script->timestamp) { if (full_path_ptr) { - efree(full_path_ptr); + zend_string_release(full_path_ptr); file_handle->opened_path = NULL; } return SUCCESS; } if (full_path_ptr) { - efree(full_path_ptr); + zend_string_release(full_path_ptr); file_handle->opened_path = NULL; } ps_handle.type = ZEND_HANDLE_FILENAME; ps_handle.filename = persistent_script->full_path->val; - ps_handle.opened_path = persistent_script->full_path->val; + ps_handle.opened_path = persistent_script->full_path; if (zend_get_file_handle_timestamp(&ps_handle, NULL) == persistent_script->timestamp) { return SUCCESS; @@ -934,8 +937,8 @@ char *accel_make_persistent_key_ex(zend_file_handle *file_handle, int path_lengt /* we don't handle this well for now. */ zend_accel_error(ACCEL_LOG_INFO, "getcwd() failed for '%s' (%d), please try to set opcache.use_cwd to 0 in ini file", file_handle->filename, errno); if (file_handle->opened_path) { - cwd = file_handle->opened_path; - cwd_len = strlen(cwd); + cwd = file_handle->opened_path->val; + cwd_len = file_handle->opened_path->len; } else { ZCG(key_len) = 0; return NULL; @@ -1047,7 +1050,7 @@ static inline char *accel_make_persistent_key(zend_file_handle *file_handle, int int zend_accel_invalidate(const char *filename, int filename_len, zend_bool force) { - char *realpath; + zend_string *realpath; zend_persistent_script *persistent_script; if (!ZCG(enabled) || !accel_startup_ok || !ZCSG(accelerator_enabled) || accelerator_shm_read_lock() != SUCCESS) { @@ -1060,12 +1063,12 @@ int zend_accel_invalidate(const char *filename, int filename_len, zend_bool forc return FAILURE; } - persistent_script = zend_accel_hash_find(&ZCSG(hash), realpath, strlen(realpath)); + persistent_script = zend_accel_hash_find(&ZCSG(hash), realpath->val, realpath->len); if (persistent_script && !persistent_script->corrupted) { zend_file_handle file_handle; file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = realpath; + file_handle.filename = realpath->val; file_handle.opened_path = realpath; if (force || @@ -1317,7 +1320,7 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han } /* check blacklist right after ensuring that file was opened */ - if (file_handle->opened_path && zend_accel_blacklist_is_blacklisted(&accel_blacklist, file_handle->opened_path)) { + if (file_handle->opened_path && zend_accel_blacklist_is_blacklisted(&accel_blacklist, file_handle->opened_path->val)) { ZCSG(blacklist_misses)++; *op_array_p = accelerator_orig_compile_file(file_handle, type); return NULL; @@ -1439,7 +1442,7 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han } if (file_handle->opened_path) { - new_persistent_script->full_path = zend_string_init(file_handle->opened_path, strlen(file_handle->opened_path), 0); + new_persistent_script->full_path = zend_string_copy(file_handle->opened_path); } else { new_persistent_script->full_path = zend_string_init(file_handle->filename, strlen(file_handle->filename), 0); } @@ -1521,7 +1524,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) } if (file_handle->opened_path && - (bucket = zend_accel_hash_find_entry(&ZCSG(hash), file_handle->opened_path, strlen(file_handle->opened_path))) != NULL) { + (bucket = zend_accel_hash_find_entry(&ZCSG(hash), file_handle->opened_path->val, file_handle->opened_path->len)) != NULL) { persistent_script = (zend_persistent_script *)bucket->data; if (!ZCG(accel_directives).revalidate_path && @@ -1702,7 +1705,7 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl (EG(current_execute_data) && (ZCG(cache_opline) == EG(current_execute_data)->opline))) { persistent_script = ZCG(cache_persistent_script); - handle->opened_path = estrndup(persistent_script->full_path->val, persistent_script->full_path->len); + handle->opened_path = zend_string_copy(persistent_script->full_path); handle->type = ZEND_HANDLE_FILENAME; return SUCCESS; #if 0 @@ -1733,7 +1736,7 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl } /* zend_resolve_path() replacement for PHP 5.3 and above */ -static char* persistent_zend_resolve_path(const char *filename, int filename_len) +static zend_string* persistent_zend_resolve_path(const char *filename, int filename_len) { if (ZCG(enabled) && accel_startup_ok && (ZCG(counted) || ZCSG(accelerator_enabled)) && @@ -1752,7 +1755,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len zend_file_handle handle; char *key = NULL; int key_length; - char *resolved_path; + zend_string *resolved_path; zend_accel_hash_entry *bucket; zend_persistent_script *persistent_script; @@ -1766,7 +1769,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len ZCG(key_len) = persistent_script->full_path->len; ZCG(cache_opline) = EG(current_execute_data) ? EG(current_execute_data)->opline : NULL; ZCG(cache_persistent_script) = persistent_script; - return estrndup(persistent_script->full_path->val, persistent_script->full_path->len); + return zend_string_copy(persistent_script->full_path); } } @@ -1783,7 +1786,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len /* we have persistent script */ ZCG(cache_opline) = EG(current_execute_data) ? EG(current_execute_data)->opline : NULL; ZCG(cache_persistent_script) = persistent_script; - return estrndup(persistent_script->full_path->val, persistent_script->full_path->len); + return zend_string_copy(persistent_script->full_path); } /* find the full real path */ @@ -1791,7 +1794,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len /* Check if requested file already cached (by real path) */ if (resolved_path && - (bucket = zend_accel_hash_find_entry(&ZCSG(hash), resolved_path, strlen(resolved_path))) != NULL) { + (bucket = zend_accel_hash_find_entry(&ZCSG(hash), resolved_path->val, resolved_path->len)) != NULL) { persistent_script = (zend_persistent_script *)bucket->data; if (persistent_script && !persistent_script->corrupted) { diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 625fe65d4e..3af08d0123 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -278,25 +278,25 @@ ZEND_INI_BEGIN() #endif ZEND_INI_END() -static int filename_is_in_cache(char *filename, int filename_len) +static int filename_is_in_cache(zend_string *filename) { char *key; int key_length; zend_file_handle handle = {{0}, NULL, NULL, 0, 0}; zend_persistent_script *persistent_script; - handle.filename = filename; + handle.filename = filename->val; handle.type = ZEND_HANDLE_FILENAME; - if (IS_ABSOLUTE_PATH(filename, filename_len)) { - persistent_script = zend_accel_hash_find(&ZCSG(hash), filename, filename_len); + if (IS_ABSOLUTE_PATH(filename->val, filename->len)) { + persistent_script = zend_accel_hash_find(&ZCSG(hash), filename->val, filename->len); if (persistent_script) { return !persistent_script->corrupted && validate_timestamp_and_record(persistent_script, &handle) == SUCCESS; } } - if ((key = accel_make_persistent_key_ex(&handle, filename_len, &key_length)) != NULL) { + if ((key = accel_make_persistent_key_ex(&handle, filename->len, &key_length)) != NULL) { persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length); return persistent_script && !persistent_script->corrupted && validate_timestamp_and_record(persistent_script, &handle) == SUCCESS; @@ -315,7 +315,7 @@ static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS) Z_STRLEN(zfilename) == 0) { return 0; } - return filename_is_in_cache(Z_STRVAL(zfilename), Z_STRLEN(zfilename)); + return filename_is_in_cache(Z_STR(zfilename)); } static void accel_file_exists(INTERNAL_FUNCTION_PARAMETERS) @@ -734,8 +734,7 @@ static ZEND_FUNCTION(opcache_compile_file) Return true if the script is cached in OPCache, false if it is not cached or if OPCache is not running. */ static ZEND_FUNCTION(opcache_is_script_cached) { - char *script_name; - size_t script_name_len; + zend_string *script_name; if (!validate_api_restriction()) { RETURN_FALSE; @@ -745,9 +744,9 @@ static ZEND_FUNCTION(opcache_is_script_cached) RETURN_FALSE; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &script_name, &script_name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &script_name) == FAILURE) { return; } - RETURN_BOOL(filename_is_in_cache(script_name, script_name_len)); + RETURN_BOOL(filename_is_in_cache(script_name)); } diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index dcfc3ddcbc..9a81dbbe3a 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -300,7 +300,7 @@ PHAR_ADD_ENTRY: /** * Open a directory handle within a phar archive */ -php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */ +php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */ { php_url *resource = NULL; php_stream *ret; diff --git a/ext/phar/dirstream.h b/ext/phar/dirstream.h index 97cc4a4cb0..b0e5f50ae4 100644 --- a/ext/phar/dirstream.h +++ b/ext/phar/dirstream.h @@ -33,7 +33,7 @@ static int phar_dir_close(php_stream *stream, int close_handle); static int phar_dir_flush(php_stream *stream); static int phar_dir_seek( php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset); #else -php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC); +php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); #endif END_EXTERN_C() diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index f71e1f34c2..e3bdf01cf1 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -118,6 +118,7 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */ if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) { char *arch, *entry, *fname; + zend_string *entry_str = NULL; int arch_len, entry_len, fname_len; php_stream_context *context = NULL; @@ -148,8 +149,8 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */ goto skip_phar; } if (use_include_path) { - if ((entry = phar_find_in_include_path(entry, entry_len, NULL))) { - name = entry; + if ((entry_str = phar_find_in_include_path(entry, entry_len, NULL))) { + name = entry_str->val; goto phar_it; } else { /* this file is not in the phar, use the original path */ @@ -188,7 +189,11 @@ phar_it: context = php_stream_context_from_zval(zcontext, 0); } stream = php_stream_open_wrapper_ex(name, "rb", 0 | REPORT_ERRORS, NULL, context); - efree(name); + if (entry_str) { + zend_string_release(entry_str); + } else { + efree(name); + } if (!stream) { RETURN_FALSE; @@ -243,6 +248,7 @@ PHAR_FUNC(phar_readfile) /* {{{ */ } if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) { char *arch, *entry, *fname; + zend_string *entry_str = NULL; int arch_len, entry_len, fname_len; php_stream_context *context = NULL; char *name; @@ -267,12 +273,12 @@ PHAR_FUNC(phar_readfile) /* {{{ */ goto skip_phar; } if (use_include_path) { - if (!(entry = phar_find_in_include_path(entry, entry_len, NULL))) { + if (!(entry_str = phar_find_in_include_path(entry, entry_len, NULL))) { /* this file is not in the phar, use the original path */ efree(arch); goto skip_phar; } else { - name = entry; + name = entry_str->val; } } else { entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1); @@ -301,7 +307,11 @@ notfound: efree(arch); context = php_stream_context_from_zval(zcontext, 0); stream = php_stream_open_wrapper_ex(name, "rb", 0 | REPORT_ERRORS, NULL, context); - efree(name); + if (entry_str) { + zend_string_release(entry_str); + } else { + efree(name); + } if (stream == NULL) { RETURN_FALSE; } @@ -339,6 +349,7 @@ PHAR_FUNC(phar_fopen) /* {{{ */ } if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) { char *arch, *entry, *fname; + zend_string *entry_str = NULL; int arch_len, entry_len, fname_len; php_stream_context *context = NULL; char *name; @@ -363,12 +374,12 @@ PHAR_FUNC(phar_fopen) /* {{{ */ goto skip_phar; } if (use_include_path) { - if (!(entry = phar_find_in_include_path(entry, entry_len, NULL))) { + if (!(entry_str = phar_find_in_include_path(entry, entry_len, NULL))) { /* this file is not in the phar, use the original path */ efree(arch); goto skip_phar; } else { - name = entry; + name = entry_str->val; } } else { entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1); @@ -398,7 +409,11 @@ notfound: efree(arch); context = php_stream_context_from_zval(zcontext, 0); stream = php_stream_open_wrapper_ex(name, mode, 0 | REPORT_ERRORS, NULL, context); - efree(name); + if (entry_str) { + zend_string_release(entry_str); + } else { + efree(name); + } if (stream == NULL) { RETURN_FALSE; } diff --git a/ext/phar/phar.c b/ext/phar/phar.c index cba275c30a..8448100f77 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -27,7 +27,7 @@ static void destroy_phar_data(zval *zv); ZEND_DECLARE_MODULE_GLOBALS(phar) -char *(*phar_save_resolve_path)(const char *filename, int filename_len); +zend_string *(*phar_save_resolve_path)(const char *filename, int filename_len); /** * set's phar->is_writeable based on the current INI value @@ -1322,7 +1322,8 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a { phar_archive_data *mydata; php_stream *fp; - char *actual = NULL, *p; + zend_string *actual = NULL; + char *p; if (!pphar) { pphar = &mydata; @@ -1340,8 +1341,8 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, &actual); if (actual) { - fname = actual; - fname_len = strlen(actual); + fname = actual->val; + fname_len = actual->len; } if (fp) { @@ -1350,20 +1351,20 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a (*pphar)->is_writeable = 1; } if (actual) { - efree(actual); + zend_string_release(actual); } return SUCCESS; } else { /* file exists, but is either corrupt or not a phar archive */ if (actual) { - efree(actual); + zend_string_release(actual); } return FAILURE; } } if (actual) { - efree(actual); + zend_string_release(actual); } if (PHAR_G(readonly) && !is_data) { @@ -1475,7 +1476,7 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error) /* {{{ */ { php_stream *fp; - char *actual; + zend_string *actual; int ret, is_data = 0; if (error) { @@ -1509,20 +1510,20 @@ int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_l } } if (actual) { - efree(actual); + zend_string_release(actual); } return FAILURE; } if (actual) { - fname = actual; - fname_len = strlen(actual); + fname = actual->val; + fname_len = actual->len; } ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error); if (actual) { - efree(actual); + zend_string_release(actual); } return ret; @@ -2252,7 +2253,7 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error) /* {{{ char *fname; php_stream *fp; int fname_len; - char *actual = NULL; + zend_string *actual = NULL; int ret; if (error) { @@ -2298,20 +2299,20 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error) /* {{{ spprintf(error, 0, "unable to open phar for reading \"%s\"", fname); } if (actual) { - efree(actual); + zend_string_release(actual); } return FAILURE; } if (actual) { - fname = actual; - fname_len = strlen(actual); + fname = actual->val; + fname_len = actual->len; } ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, 0, error); if (actual) { - efree(actual); + zend_string_release(actual); } return ret; @@ -3254,7 +3255,7 @@ static size_t phar_zend_stream_fsizer(void *handle) /* {{{ */ zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type); #define phar_orig_zend_open zend_stream_open_function -static char *phar_resolve_path(const char *filename, int filename_len) +static zend_string *phar_resolve_path(const char *filename, int filename_len) { return phar_find_in_include_path((char *) filename, filename_len, NULL); } diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 0f8323f065..ccff36770b 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -495,7 +495,7 @@ union _phar_entry_object { #endif #ifndef PHAR_MAIN -extern char *(*phar_save_resolve_path)(const char *filename, int filename_len); +extern zend_string *(*phar_save_resolve_path)(const char *filename, int filename_len); #endif BEGIN_EXTERN_C() @@ -562,7 +562,7 @@ char *phar_compress_filter(phar_entry_info * entry, int return_unknown); void phar_remove_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len); void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename_len); int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len); -char *phar_find_in_include_path(char *file, int file_len, phar_archive_data **pphar); +zend_string *phar_find_in_include_path(char *file, int file_len, phar_archive_data **pphar); char *phar_fix_filepath(char *path, int *new_len, int use_cwd); phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error); int phar_parse_metadata(char **buffer, zval *metadata, int zip_metadata_len); diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 0b173d1e0b..d5f84b87de 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1399,11 +1399,11 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ phar_entry_data *data; php_stream *fp; size_t contents_len; - char *fname, *error = NULL, *base = p_obj->b, *opened, *save = NULL, *temp = NULL; + char *fname, *error = NULL, *base = p_obj->b, *save = NULL, *temp = NULL; + zend_string *opened; char *str_key; zend_class_entry *ce = p_obj->c; phar_archive_object *phar_obj = p_obj->p; - char *str = "[stream]"; value = iter->funcs->get_current_data(iter); @@ -1453,7 +1453,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ } close_fp = 0; - opened = (char *) estrndup(str, sizeof("[stream]") - 1); + opened = zend_string_init("[stream]", sizeof("[stream]") - 1, 0); goto after_open_fp; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(value), spl_ce_SplFileInfo)) { @@ -1638,7 +1638,7 @@ after_open_fp: } if (opened) { - efree(opened); + zend_string_release(opened); } if (close_fp) { @@ -1657,7 +1657,7 @@ after_open_fp: } if (opened) { - efree(opened); + zend_string_release(opened); } if (temp) { @@ -1692,9 +1692,7 @@ after_open_fp: php_stream_close(fp); } - // TODO: avoid reallocation ??? - add_assoc_string(p_obj->ret, str_key, opened); - efree(opened); + add_assoc_str(p_obj->ret, str_key, opened); if (save) { efree(save); @@ -4202,7 +4200,7 @@ PHP_METHOD(Phar, extractTo) php_stream *fp; php_stream_statbuf ssb; phar_entry_info *entry; - char *pathto, *filename, *actual; + char *pathto, *filename; size_t pathto_len, filename_len; int ret, i; int nelems; @@ -4215,7 +4213,7 @@ PHP_METHOD(Phar, extractTo) return; } - fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, &actual); + fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, NULL); if (!fp) { zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, @@ -4223,7 +4221,6 @@ PHP_METHOD(Phar, extractTo) return; } - efree(actual); php_stream_close(fp); if (pathto_len < 1) { diff --git a/ext/phar/stream.c b/ext/phar/stream.c index ac40b3e8dc..e05b1663c2 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -155,7 +155,7 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const /** * used for fopen('phar://...') and company */ -static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */ +static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */ { phar_archive_data *phar; phar_entry_data *idata; @@ -231,7 +231,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha } } if (opened_path) { - spprintf(opened_path, MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename); + *opened_path = zend_strpprintf(MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename); } return fpf; } else { @@ -249,7 +249,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha } efree(internal_file); if (opened_path) { - spprintf(opened_path, MAXPATHLEN, "%s", phar->fname); + *opened_path = zend_strpprintf(MAXPATHLEN, "%s", phar->fname); } php_url_free(resource); goto phar_stub; @@ -275,7 +275,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha ++(entry->fp_refcount); php_url_free(resource); if (opened_path) { - spprintf(opened_path, MAXPATHLEN, "%s", phar->fname); + *opened_path = zend_strpprintf(MAXPATHLEN, "%s", phar->fname); } efree(internal_file); goto phar_stub; @@ -332,7 +332,7 @@ idata_error: } } if (opened_path) { - spprintf(opened_path, MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename); + *opened_path = zend_strpprintf(MAXPATHLEN, "phar://%s/%s", idata->phar->fname, idata->internal_file->filename); } efree(internal_file); phar_stub: diff --git a/ext/phar/stream.h b/ext/phar/stream.h index dc798c0d1b..2b637c0caf 100644 --- a/ext/phar/stream.h +++ b/ext/phar/stream.h @@ -24,7 +24,7 @@ BEGIN_EXTERN_C() php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options); void phar_entry_remove(phar_entry_data *idata, char **error); -static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC); +static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context); static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context); static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context); diff --git a/ext/phar/util.c b/ext/phar/util.c index 1c10ab13e0..190f69cf61 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -250,10 +250,11 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, } /* }}} */ -char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_data **pphar) /* {{{ */ +zend_string *phar_find_in_include_path(char *filename, int filename_len, phar_archive_data **pphar) /* {{{ */ { - char *path, *fname, *arch, *entry, *ret, *test; - int arch_len, entry_len, fname_len, ret_len; + zend_string *ret; + char *path, *fname, *arch, *entry, *test; + int arch_len, entry_len, fname_len; phar_archive_data *phar; if (pphar) { @@ -299,14 +300,14 @@ splitted: if (*test == '/') { if (zend_hash_str_exists(&(phar->manifest), test + 1, try_len - 1)) { - spprintf(&ret, 0, "phar://%s%s", arch, test); + ret = zend_strpprintf(0, "phar://%s%s", arch, test); efree(arch); efree(test); return ret; } } else { if (zend_hash_str_exists(&(phar->manifest), test, try_len)) { - spprintf(&ret, 0, "phar://%s/%s", arch, test); + ret = zend_strpprintf(0, "phar://%s/%s", arch, test); efree(arch); efree(test); return ret; @@ -320,11 +321,9 @@ splitted: ret = php_resolve_path(filename, filename_len, path); efree(path); - if (ret && strlen(ret) > 8 && !strncmp(ret, "phar://", 7)) { - ret_len = strlen(ret); + if (ret && ret->len > 8 && !strncmp(ret->val, "phar://", 7)) { /* found phar:// */ - - if (SUCCESS != phar_split_fname(ret, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0)) { + if (SUCCESS != phar_split_fname(ret->val, ret->len, &arch, &arch_len, &entry, &entry_len, 1, 0)) { return ret; } diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 9c7dc5caff..f16734422b 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -273,9 +273,9 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha if (ret == SUCCESS) { zend_string *opened_path; if (!file_handle.opened_path) { - file_handle.opened_path = estrndup(class_file, class_file_len); + file_handle.opened_path = zend_string_init(class_file, class_file_len, 0); } - opened_path = zend_string_init(file_handle.opened_path, strlen(file_handle.opened_path), 0); + opened_path = zend_string_copy(file_handle.opened_path); ZVAL_NULL(&dummy); if (zend_hash_add(&EG(included_files), opened_path, &dummy)) { new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE); diff --git a/ext/standard/file.c b/ext/standard/file.c index 3599313a71..dae4235a99 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -802,7 +802,7 @@ PHP_FUNCTION(tempnam) { char *dir, *prefix; size_t dir_len, prefix_len; - char *opened_path; + zend_string *opened_path; int fd; zend_string *p; @@ -823,9 +823,7 @@ PHP_FUNCTION(tempnam) if ((fd = php_open_temporary_fd_ex(dir, p->val, &opened_path, 1)) >= 0) { close(fd); - // TODO: avoid reallocation ??? - RETVAL_STRING(opened_path); - efree(opened_path); + RETVAL_STR(opened_path); } zend_string_release(p); } diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index 1c83a9434c..b003ffda0f 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -131,7 +131,7 @@ static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper, php_stream * /* {{{ php_ftp_fopen_connect */ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, - char **opened_path, php_stream_context *context, php_stream **preuseid, + zend_string **opened_path, php_stream_context *context, php_stream **preuseid, php_url **presource, int *puse_ssl, int *puse_ssl_on_data) { php_stream *stream = NULL, *reuseid = NULL; @@ -412,7 +412,7 @@ static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, size_t ip_ /* {{{ php_fopen_url_wrap_ftp */ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *path, const char *mode, - int options, char **opened_path, php_stream_context *context STREAMS_DC) + int options, zend_string **opened_path, php_stream_context *context STREAMS_DC) { php_stream *stream = NULL, *datastream = NULL; php_url *resource = NULL; @@ -684,7 +684,7 @@ static php_stream_ops php_ftp_dirstream_ops = { /* {{{ php_stream_ftp_opendir */ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, - char **opened_path, php_stream_context *context STREAMS_DC) + zend_string **opened_path, php_stream_context *context STREAMS_DC) { php_stream *stream, *reuseid, *datastream = NULL; php_ftp_dirstream_data *dirsdata; diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 6e0ea812a4..1f54f62c6c 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -110,7 +110,7 @@ static inline void strip_header(char *header_bag, char *lc_header_bag, } php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, - const char *path, const char *mode, int options, char **opened_path, + const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context, int redirect_max, int flags STREAMS_DC) /* {{{ */ { php_stream *stream = NULL; @@ -933,7 +933,7 @@ out: } /* }}} */ -php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */ +php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */ { return php_stream_url_wrap_http_ex(wrapper, path, mode, options, opened_path, context, PHP_URL_REDIRECT_MAX, HTTP_WRAPPER_HEADER_INIT STREAMS_CC); } diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 5e85d4dc43..1dc6a21cf5 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -172,7 +172,7 @@ static void php_stream_apply_filter_list(php_stream *stream, char *filterlist, i /* }}} */ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, - char **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */ + zend_string **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */ { int fd = -1; int mode_rw = 0; @@ -345,6 +345,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa efree(pathdup); return NULL; } + if (!(stream = php_stream_open_wrapper(p + 10, mode, options, opened_path))) { efree(pathdup); return NULL; diff --git a/ext/standard/php_fopen_wrappers.h b/ext/standard/php_fopen_wrappers.h index 5217144755..3773edbc5d 100644 --- a/ext/standard/php_fopen_wrappers.h +++ b/ext/standard/php_fopen_wrappers.h @@ -23,8 +23,8 @@ #ifndef PHP_FOPEN_WRAPPERS_H #define PHP_FOPEN_WRAPPERS_H -php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC); -php_stream *php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC); +php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); +php_stream *php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); extern PHPAPI php_stream_wrapper php_stream_http_wrapper; extern PHPAPI php_stream_wrapper php_stream_ftp_wrapper; extern PHPAPI php_stream_wrapper php_stream_php_wrapper; diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 46c2aaa9a1..a86aae25f0 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -1489,8 +1489,9 @@ PHP_FUNCTION(stream_socket_enable_crypto) Determine what file will be opened by calls to fopen() with a relative path */ PHP_FUNCTION(stream_resolve_include_path) { - char *filename, *resolved_path; + char *filename; size_t filename_len; + zend_string *resolved_path; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) { return; @@ -1499,10 +1500,7 @@ PHP_FUNCTION(stream_resolve_include_path) resolved_path = zend_resolve_path(filename, (int)filename_len); if (resolved_path) { - // TODO: avoid reallocation ??? - RETVAL_STRING(resolved_path); - efree(resolved_path); - return; + RETURN_STR(resolved_path); } RETURN_FALSE; } diff --git a/ext/zip/php_zip.h b/ext/zip/php_zip.h index a1ae3d5d6f..31099053ef 100644 --- a/ext/zip/php_zip.h +++ b/ext/zip/php_zip.h @@ -90,7 +90,7 @@ static inline ze_zip_object *php_zip_fetch_object(zend_object *obj) { #define Z_ZIP_P(zv) php_zip_fetch_object(Z_OBJ_P((zv))) -php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC); +php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); php_stream *php_stream_zip_open(const char *filename, const char *path, const char *mode STREAMS_DC); extern php_stream_wrapper php_stream_zip_wrapper; diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index d56213d1d5..18707eed27 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -254,7 +254,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, - char **opened_path, + zend_string **opened_path, php_stream_context *context STREAMS_DC) { int path_len; @@ -314,7 +314,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, stream = php_stream_alloc(&php_stream_zipio_ops, self, NULL, mode); if (opened_path) { - *opened_path = estrdup(path); + *opened_path = zend_string_init(path, strlen(path), 0); } } else { zip_close(za); diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index 1ecf593e69..2a8e443eba 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -58,7 +58,7 @@ ZEND_BEGIN_MODULE_GLOBALS(zlib) int compression_coding; ZEND_END_MODULE_GLOBALS(zlib); -php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC); +php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); extern php_stream_ops php_stream_gzio_ops; extern php_stream_wrapper php_stream_gzip_wrapper; extern php_stream_filter_factory php_zlib_filter_factory; diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c index 8b17eca12b..6e63cc2641 100644 --- a/ext/zlib/zlib_fopen_wrapper.c +++ b/ext/zlib/zlib_fopen_wrapper.c @@ -111,7 +111,7 @@ php_stream_ops php_stream_gzio_ops = { }; php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, - char **opened_path, php_stream_context *context STREAMS_DC) + zend_string **opened_path, php_stream_context *context STREAMS_DC) { struct php_gz_stream_data_t *self; php_stream *stream = NULL, *innerstream = NULL; |