Skip to content

Commit a72c53a

Browse files
committed
Fixed bug #79817
Use *_IND macros in a few places in string.c.
1 parent 23ef0a1 commit a72c53a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ PHP NEWS
3030

3131
- Standard:
3232
. Fixed bug #70362 (Can't copy() large 'data://' with open_basedir). (cmb)
33+
. Fixed bug #79817 (str_replace() does not handle INDIRECT elements). (Nikita)
3334

3435
?? ??? ????, PHP 7.3.20
3536

ext/standard/string.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@ PHP_FUNCTION(substr_replace)
26102610

26112611
from_idx = len_idx = repl_idx = 0;
26122612

2613-
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(str), num_index, str_index, tmp_str) {
2613+
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(str), num_index, str_index, tmp_str) {
26142614
zend_string *tmp_orig_str;
26152615
zend_string *orig_str = zval_get_tmp_string(tmp_str, &tmp_orig_str);
26162616

@@ -3062,7 +3062,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
30623062
zend_string *key_used;
30633063
/* we have to rebuild HashTable with numeric keys */
30643064
zend_hash_init(&str_hash, zend_hash_num_elements(pats), NULL, NULL, 0);
3065-
ZEND_HASH_FOREACH_KEY_VAL(pats, num_key, str_key, entry) {
3065+
ZEND_HASH_FOREACH_KEY_VAL_IND(pats, num_key, str_key, entry) {
30663066
if (UNEXPECTED(!str_key)) {
30673067
key_used = zend_long_to_str(num_key);
30683068
len = ZSTR_LEN(key_used);
@@ -3508,7 +3508,7 @@ PHP_FUNCTION(strtr)
35083508
zend_string *str_key, *tmp_str, *replace, *tmp_replace;
35093509
zval *entry;
35103510

3511-
ZEND_HASH_FOREACH_KEY_VAL(pats, num_key, str_key, entry) {
3511+
ZEND_HASH_FOREACH_KEY_VAL_IND(pats, num_key, str_key, entry) {
35123512
tmp_str = NULL;
35133513
if (UNEXPECTED(!str_key)) {
35143514
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
43034303
}
43044304

43054305
/* For each entry in the search array, get the entry */
4306-
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(search), search_entry) {
4306+
ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL_P(search), search_entry) {
43074307
/* Make sure we're dealing with strings. */
43084308
zend_string *tmp_search_str;
43094309
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
44634463

44644464
/* For each subject entry, convert it to string, then perform replacement
44654465
and add the result to the return_value array. */
4466-
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(subject), num_key, string_key, subject_entry) {
4466+
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(subject), num_key, string_key, subject_entry) {
44674467
ZVAL_DEREF(subject_entry);
44684468
if (Z_TYPE_P(subject_entry) != IS_ARRAY && Z_TYPE_P(subject_entry) != IS_OBJECT) {
44694469
count += php_str_replace_in_subject(search, replace, subject_entry, &result, case_sensitivity);

0 commit comments

Comments
 (0)