summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.c
diff options
context:
space:
mode:
authorJoe Watkins <krakjoe@php.net>2016-02-10 12:58:19 +0000
committerJoe Watkins <krakjoe@php.net>2016-02-10 12:58:19 +0000
commitdaf3d0c875634547748b791fb6291e78103bf6dc (patch)
tree667c296cf01f1d81a0b0199eb2245c6abb1fed19 /ext/pcre/php_pcre.c
parent3ac63df9bc27226c25cca5c87804896d33a7ab4f (diff)
parentaeb5319336aa447ad24968479b8aa249dd4c43a7 (diff)
downloadphp-git-daf3d0c875634547748b791fb6291e78103bf6dc.tar.gz
Merge branch 'PHP-7.0' of https://github.com/php/php-src into PHP-7.0
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r--ext/pcre/php_pcre.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index ee3e36b6ab..93bfc00052 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -1350,7 +1350,6 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *subject, int limit, int is_callable_replace, int *replace_count)
{
zval *regex_entry,
- *replace_entry = NULL,
*replace_value,
empty_replace;
zend_string *result;
@@ -1372,25 +1371,26 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub
/* For each entry in the regex array, get the entry */
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(regex), regex_entry) {
+ zval replace_str;
/* Make sure we're dealing with strings. */
zend_string *regex_str = zval_get_string(regex_entry);
+ ZVAL_UNDEF(&replace_str);
/* If replace is an array and not a callable construct */
if (Z_TYPE_P(replace) == IS_ARRAY && !is_callable_replace) {
/* Get current entry */
- replace_entry = NULL;
while (replace_idx < Z_ARRVAL_P(replace)->nNumUsed) {
if (Z_TYPE(Z_ARRVAL_P(replace)->arData[replace_idx].val) != IS_UNDEF) {
- replace_entry = &Z_ARRVAL_P(replace)->arData[replace_idx].val;
+ ZVAL_COPY(&replace_str, &Z_ARRVAL_P(replace)->arData[replace_idx].val);
break;
}
replace_idx++;
}
- if (replace_entry != NULL) {
+ if (!Z_ISUNDEF(replace_str)) {
if (!is_callable_replace) {
- convert_to_string_ex(replace_entry);
+ convert_to_string(&replace_str);
}
- replace_value = replace_entry;
+ replace_value = &replace_str;
replace_idx++;
} else {
/* We've run out of replacement strings, so use an empty one */
@@ -1413,10 +1413,12 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub
} else {
zend_string_release(subject_str);
zend_string_release(regex_str);
+ zval_dtor(&replace_str);
return NULL;
}
zend_string_release(regex_str);
+ zval_dtor(&replace_str);
} ZEND_HASH_FOREACH_END();
return subject_str;