]> granicus.if.org Git - php/commitdiff
Fixed bug #79817
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 10 Jul 2020 12:06:41 +0000 (14:06 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 10 Jul 2020 12:06:41 +0000 (14:06 +0200)
Use *_IND macros in a few places in string.c.

NEWS
ext/standard/string.c

diff --git a/NEWS b/NEWS
index 071e456a8894b442a74b349ec1c231cf2273b695..b230a84c5c6b1c600d7931a81fab00e546d15262 100644 (file)
--- 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
 
index 38180106d547de9618e12f8709cf24cf26dba2bc..ba66d3c3ac42394ead8956215dd40332ff55a514 100644 (file)
@@ -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);