diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-05-28 12:39:27 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-05-28 12:39:27 +0400 |
commit | 2625f145c8881db800402c5e70c74dfa6d7c1cbb (patch) | |
tree | 4951a195e544f2cc7b3c50ca507a5196b8f3fd2f /ext/pcre/php_pcre.c | |
parent | c9062917ebac6d2726360fca6ae3e3ac3a964e0e (diff) | |
download | php-git-2625f145c8881db800402c5e70c74dfa6d7c1cbb.tar.gz |
Use extended iteration API to avoid in-place modification
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r-- | ext/pcre/php_pcre.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 952dcb11bd..193234c131 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1271,6 +1271,7 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub empty_replace; zend_string *result; zend_string *subject_str = zval_get_string(subject); + HashPosition pos; /* FIXME: This might need to be changed to STR_EMPTY_ALLOC(). Check if this zval could be dtor()'ed somehow */ ZVAL_EMPTY_STRING(&empty_replace); @@ -1279,7 +1280,7 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub if (Z_TYPE_P(regex) == IS_ARRAY) { replace_value = replace; if (Z_TYPE_P(replace) == IS_ARRAY && !is_callable_replace) - zend_hash_internal_pointer_reset(Z_ARRVAL_P(replace)); + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(replace), &pos); /* For each entry in the regex array, get the entry */ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(regex), regex_entry) { @@ -1289,12 +1290,12 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub /* If replace is an array and not a callable construct */ if (Z_TYPE_P(replace) == IS_ARRAY && !is_callable_replace) { /* Get current entry */ - if ((replace_entry = zend_hash_get_current_data(Z_ARRVAL_P(replace))) != NULL) { + if ((replace_entry = zend_hash_get_current_data_ex(Z_ARRVAL_P(replace), &pos)) != NULL) { if (!is_callable_replace) { convert_to_string_ex(replace_entry); } replace_value = replace_entry; - zend_hash_move_forward(Z_ARRVAL_P(replace)); + zend_hash_move_forward_ex(Z_ARRVAL_P(replace), &pos); } else { /* We've run out of replacement strings, so use an empty one */ replace_value = &empty_replace; |