summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-07-10 14:06:41 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-07-10 14:06:41 +0200
commita72c53a0707db617ba0cf55d639bc188c3aa8ede (patch)
tree1b4717b46822bcf64060b467931a17c4c0f8316f
parent23ef0a12851012d6738e4fa01bd9e56005e6b88e (diff)
downloadphp-git-a72c53a0707db617ba0cf55d639bc188c3aa8ede.tar.gz
Fixed bug #79817
Use *_IND macros in a few places in string.c.
-rw-r--r--NEWS1
-rw-r--r--ext/standard/string.c10
2 files changed, 6 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 071e456a88..b230a84c5c 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,7 @@ PHP NEWS
- Standard:
. Fixed bug #70362 (Can't copy() large 'data://' with open_basedir). (cmb)
+ . Fixed bug #79817 (str_replace() does not handle INDIRECT elements). (Nikita)
?? ??? ????, PHP 7.3.20
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 38180106d5..ba66d3c3ac 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2610,7 +2610,7 @@ PHP_FUNCTION(substr_replace)
from_idx = len_idx = repl_idx = 0;
- ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(str), num_index, str_index, tmp_str) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(str), num_index, str_index, tmp_str) {
zend_string *tmp_orig_str;
zend_string *orig_str = zval_get_tmp_string(tmp_str, &tmp_orig_str);
@@ -3062,7 +3062,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
zend_string *key_used;
/* we have to rebuild HashTable with numeric keys */
zend_hash_init(&str_hash, zend_hash_num_elements(pats), NULL, NULL, 0);
- ZEND_HASH_FOREACH_KEY_VAL(pats, num_key, str_key, entry) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(pats, num_key, str_key, entry) {
if (UNEXPECTED(!str_key)) {
key_used = zend_long_to_str(num_key);
len = ZSTR_LEN(key_used);
@@ -3508,7 +3508,7 @@ PHP_FUNCTION(strtr)
zend_string *str_key, *tmp_str, *replace, *tmp_replace;
zval *entry;
- ZEND_HASH_FOREACH_KEY_VAL(pats, num_key, str_key, entry) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(pats, num_key, str_key, entry) {
tmp_str = NULL;
if (UNEXPECTED(!str_key)) {
str_key = tmp_str = zend_long_to_str(num_key);
@@ -4303,7 +4303,7 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
}
/* For each entry in the search array, get the entry */
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(search), search_entry) {
+ ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL_P(search), search_entry) {
/* Make sure we're dealing with strings. */
zend_string *tmp_search_str;
zend_string *search_str = zval_get_tmp_string(search_entry, &tmp_search_str);
@@ -4463,7 +4463,7 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
/* For each subject entry, convert it to string, then perform replacement
and add the result to the return_value array. */
- ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(subject), num_key, string_key, subject_entry) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(subject), num_key, string_key, subject_entry) {
ZVAL_DEREF(subject_entry);
if (Z_TYPE_P(subject_entry) != IS_ARRAY && Z_TYPE_P(subject_entry) != IS_OBJECT) {
count += php_str_replace_in_subject(search, replace, subject_entry, &result, case_sensitivity);