com php-src: fix failure with shared zvals in php_str_repla ce_in_subject: ext/standard/string.c

From: Date: Tue, 27 Jan 2015 10:16:22 +0000
Subject: com php-src: fix failure with shared zvals in php_str_repla ce_in_subject: ext/standard/string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-84386@lists.php.net to get a copy of this message
Commit: f869bf3829c6b2c94011747c69ed8f32412c9e03 Author: Márcio Almada <marcio3w@gmail.com> Fri, 23 Jan 2015 17:23:35 -0300 Parents: 1c0dcb268cd7bd8710b578cb671b4380ff412823 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f869bf3829c6b2c94011747c69ed8f32412c9e03 Log: fix failure with shared zvals in php_str_replace_in_subject Changed paths: M ext/standard/string..c Diff: diff --git a/ext/standard/string.c b/ext/standard/string..c index e22dba3..b51aaa1 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3958,7 +3958,8 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s { zval *search_entry, *replace_entry = NULL; - zend_string *tmp_result; + zend_string *tmp_result, + *replace_entry_str = NULL; char *replace_value = NULL; size_t replace_len = 0; zend_long replace_count = 0; @@ -3990,7 +3991,8 @@ 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) { /* Make sure we're dealing with strings. */ - SEPARATE_ZVAL(search_entry); + ZVAL_DEREF(search_entry); + SEPARATE_ZVAL_NOREF(search_entry); convert_to_string(search_entry); if (Z_STRLEN_P(search_entry) == 0) { if (Z_TYPE_P(replace) == IS_ARRAY) { @@ -4004,11 +4006,11 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s /* Get current entry */ if ((replace_entry = zend_hash_get_current_data_ex(Z_ARRVAL_P(replace), &pos)) != NULL) { /* Make sure we're dealing with strings. */ - convert_to_string_ex(replace_entry); + replace_entry_str = zval_get_string(replace_entry); /* Set replacement value to the one we got from array */ - replace_value = Z_STRVAL_P(replace_entry); - replace_len = Z_STRLEN_P(replace_entry); + replace_value = replace_entry_str->val; + replace_len = replace_entry_str->len; zend_hash_move_forward_ex(Z_ARRVAL_P(replace), &pos); } else { @@ -4051,6 +4053,9 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s } } + if(replace_entry_str) { + zend_string_release(replace_entry_str); + } zend_string_release(Z_STR_P(result)); ZVAL_STR(result, tmp_result);

« previous php.cvs (#84386) next »