summaryrefslogtreecommitdiff
path: root/ext/zip
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-05-28 16:27:12 +0300
committerDmitry Stogov <dmitry@zend.com>2018-05-28 16:27:12 +0300
commit5eb1f92f31cafc48384f9096012f421b37f6d425 (patch)
tree4ed67b92229407e7b5cbab37b96428fe80eb3f94 /ext/zip
parent925f05dd1a35eafa71eb29abb69cdfc31a23a75d (diff)
downloadphp-git-5eb1f92f31cafc48384f9096012f421b37f6d425.tar.gz
Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence.
Diffstat (limited to 'ext/zip')
-rw-r--r--ext/zip/php_zip.c30
-rw-r--r--ext/zip/zip_stream.c10
2 files changed, 20 insertions, 20 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 815f64ecb4..a98c8cc555 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -191,7 +191,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname_fullpath)) {
efree(file_dirname_fullpath);
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
CWD_STATE_FREE(new_state.cwd);
return 0;
}
@@ -203,7 +203,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
if (!ret) {
efree(file_dirname_fullpath);
if (!is_dir_only) {
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
CWD_STATE_FREE(new_state.cwd);
}
return 0;
@@ -220,13 +220,13 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
len = spprintf(&fullpath, 0, "%s/%s", file_dirname_fullpath, ZSTR_VAL(file_basename));
if (!len) {
efree(file_dirname_fullpath);
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
CWD_STATE_FREE(new_state.cwd);
return 0;
} else if (len > MAXPATHLEN) {
php_error_docref(NULL, E_WARNING, "Full extraction path exceed MAXPATHLEN (%i)", MAXPATHLEN);
efree(file_dirname_fullpath);
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
CWD_STATE_FREE(new_state.cwd);
return 0;
}
@@ -238,7 +238,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
if (ZIP_OPENBASEDIR_CHECKPATH(fullpath)) {
efree(fullpath);
efree(file_dirname_fullpath);
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
CWD_STATE_FREE(new_state.cwd);
return 0;
}
@@ -268,7 +268,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
done:
efree(fullpath);
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
efree(file_dirname_fullpath);
CWD_STATE_FREE(new_state.cwd);
@@ -673,14 +673,14 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
if ((namelist_len == 1 && ZSTR_VAL(namelist[i])[0] == '.') ||
(namelist_len == 2 && ZSTR_VAL(namelist[i])[0] == '.' && ZSTR_VAL(namelist[i])[1] == '.')) {
- zend_string_release(namelist[i]);
+ zend_string_release_ex(namelist[i], 0);
continue;
}
if ((path_len + namelist_len + 1) >= MAXPATHLEN) {
php_error_docref(NULL, E_WARNING, "add_path string too long (max: %u, %zu given)",
MAXPATHLEN - 1, (path_len + namelist_len + 1));
- zend_string_release(namelist[i]);
+ zend_string_release_ex(namelist[i], 0);
break;
}
@@ -688,31 +688,31 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
if (0 != VCWD_STAT(fullpath, &s)) {
php_error_docref(NULL, E_WARNING, "Cannot read <%s>", fullpath);
- zend_string_release(namelist[i]);
+ zend_string_release_ex(namelist[i], 0);
continue;
}
if (S_IFDIR == (s.st_mode & S_IFMT)) {
- zend_string_release(namelist[i]);
+ zend_string_release_ex(namelist[i], 0);
continue;
}
match_data = php_pcre_create_match_data(capture_count, re);
if (!match_data) {
/* Allocation failed, but can proceed to the next pattern. */
- zend_string_release(namelist[i]);
+ zend_string_release_ex(namelist[i], 0);
continue;
}
rc = pcre2_match(re, (PCRE2_SPTR)ZSTR_VAL(namelist[i]), ZSTR_LEN(namelist[i]), 0, preg_options, match_data, mctx);
php_pcre_free_match_data(match_data);
/* 0 means that the vector is too small to hold all the captured substring offsets */
if (rc < 0) {
- zend_string_release(namelist[i]);
+ zend_string_release_ex(namelist[i], 0);
continue;
}
add_next_index_string(return_value, fullpath);
- zend_string_release(namelist[i]);
+ zend_string_release_ex(namelist[i], 0);
}
efree(namelist);
}
@@ -820,7 +820,7 @@ static void php_zip_register_prop_handler(HashTable *prop_handler, char *name, z
/* Register for reflection */
ZVAL_NULL(&tmp);
zend_declare_property_ex(zip_class_entry, str, &tmp, ZEND_ACC_PUBLIC, NULL);
- zend_string_release(str);
+ zend_string_release_ex(str, 1);
}
/* }}} */
@@ -1760,7 +1760,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
entry_name = entry_name_buf;
entry_name_len = strlen(entry_name);
if (basename) {
- zend_string_release(basename);
+ zend_string_release_ex(basename, 0);
basename = NULL;
}
diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c
index 00caae6ccb..331ff4d9b1 100644
--- a/ext/zip/zip_stream.c
+++ b/ext/zip/zip_stream.c
@@ -161,7 +161,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{
fragment++;
if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) {
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
return -1;
}
@@ -170,7 +170,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{
memset(ssb, 0, sizeof(php_stream_statbuf));
if (zip_stat(za, fragment, ZIP_FL_NOCASE, &sb) != 0) {
zip_close(za);
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
return -1;
}
zip_close(za);
@@ -194,7 +194,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{
#endif
ssb->sb.st_ino = -1;
}
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
return 0;
}
/* }}} */
@@ -306,7 +306,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper,
fragment++;
if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) {
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
return NULL;
}
@@ -338,7 +338,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper,
}
}
- zend_string_release(file_basename);
+ zend_string_release_ex(file_basename, 0);
if (!stream) {
return NULL;