@@ -2142,9 +2142,8 @@ static zend_always_inline zend_string *php_replace_in_subject(
2142
2142
}
2143
2143
/* }}} */
2144
2144
2145
- /* {{{ php_replace_in_subject_func */
2146
- static zend_string * php_replace_in_subject_func (zend_string * regex_str , HashTable * regex_ht ,
2147
- zend_fcall_info * fci , zend_fcall_info_cache * fcc ,
2145
+ static zend_string * php_replace_in_subject_func (zend_string * regex_str , const HashTable * regex_ht ,
2146
+ zend_fcall_info_cache * fcc ,
2148
2147
zend_string * subject , size_t limit , size_t * replace_count , zend_long flags )
2149
2148
{
2150
2149
zend_string * result ;
@@ -2164,7 +2163,10 @@ static zend_string *php_replace_in_subject_func(zend_string *regex_str, HashTabl
2164
2163
ZEND_HASH_FOREACH_VAL (regex_ht , regex_entry ) {
2165
2164
/* Make sure we're dealing with strings. */
2166
2165
zend_string * tmp_regex_entry_str ;
2167
- zend_string * regex_entry_str = zval_get_tmp_string (regex_entry , & tmp_regex_entry_str );
2166
+ zend_string * regex_entry_str = zval_try_get_tmp_string (regex_entry , & tmp_regex_entry_str );
2167
+ if (UNEXPECTED (regex_entry_str == NULL )) {
2168
+ break ;
2169
+ }
2168
2170
2169
2171
/* Do the actual replacement and put the result back into subject
2170
2172
for further replacements. */
@@ -2181,7 +2183,6 @@ static zend_string *php_replace_in_subject_func(zend_string *regex_str, HashTabl
2181
2183
return subject ;
2182
2184
}
2183
2185
}
2184
- /* }}} */
2185
2186
2186
2187
/* {{{ preg_replace_func_impl */
2187
2188
static size_t preg_replace_func_impl (zval * return_value ,
@@ -2194,7 +2195,7 @@ static size_t preg_replace_func_impl(zval *return_value,
2194
2195
2195
2196
if (subject_str ) {
2196
2197
result = php_replace_in_subject_func (
2197
- regex_str , regex_ht , fci , fcc , subject_str , limit_val , & replace_count , flags );
2198
+ regex_str , regex_ht , fcc , subject_str , limit_val , & replace_count , flags );
2198
2199
if (result != NULL ) {
2199
2200
RETVAL_STR (result );
2200
2201
} else {
@@ -2218,7 +2219,7 @@ static size_t preg_replace_func_impl(zval *return_value,
2218
2219
zend_string * subject_entry_str = zval_get_tmp_string (subject_entry , & tmp_subject_entry_str );
2219
2220
2220
2221
result = php_replace_in_subject_func (
2221
- regex_str , regex_ht , fci , fcc , subject_entry_str , limit_val , & replace_count , flags );
2222
+ regex_str , regex_ht , fcc , subject_entry_str , limit_val , & replace_count , flags );
2222
2223
if (result != NULL ) {
2223
2224
/* Add to return array */
2224
2225
ZVAL_STR (& zv , result );
0 commit comments