From: Nikita Popov Date: Fri, 10 Jul 2020 12:06:41 +0000 (+0200) Subject: Fixed bug #79817 X-Git-Tag: php-7.3.21RC1~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a72c53a0707db617ba0cf55d639bc188c3aa8ede;p=php Fixed bug #79817 Use *_IND macros in a few places in string.c. --- 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);