@@ -2183,11 +2183,10 @@ static zend_string *php_replace_in_subject_func(zend_string *regex_str, const Ha
2183
2183
}
2184
2184
}
2185
2185
2186
- /* {{{ preg_replace_func_impl */
2187
- static size_t preg_replace_func_impl (zval * return_value ,
2188
- zend_string * regex_str , HashTable * regex_ht ,
2189
- zend_fcall_info * fci , zend_fcall_info_cache * fcc ,
2190
- zend_string * subject_str , HashTable * subject_ht , zend_long limit_val , zend_long flags )
2186
+ static size_t php_preg_replace_func_impl (zval * return_value ,
2187
+ zend_string * regex_str , const HashTable * regex_ht ,
2188
+ zend_fcall_info_cache * fcc ,
2189
+ zend_string * subject_str , const HashTable * subject_ht , zend_long limit_val , zend_long flags )
2191
2190
{
2192
2191
zend_string * result ;
2193
2192
size_t replace_count = 0 ;
@@ -2215,7 +2214,10 @@ static size_t preg_replace_func_impl(zval *return_value,
2215
2214
and add the result to the return_value array. */
2216
2215
ZEND_HASH_FOREACH_KEY_VAL (subject_ht , num_key , string_key , subject_entry ) {
2217
2216
zend_string * tmp_subject_entry_str ;
2218
- zend_string * subject_entry_str = zval_get_tmp_string (subject_entry , & tmp_subject_entry_str );
2217
+ zend_string * subject_entry_str = zval_try_get_tmp_string (subject_entry , & tmp_subject_entry_str );
2218
+ if (UNEXPECTED (subject_entry_str == NULL )) {
2219
+ break ;
2220
+ }
2219
2221
2220
2222
result = php_replace_in_subject_func (
2221
2223
regex_str , regex_ht , fcc , subject_entry_str , limit_val , & replace_count , flags );
@@ -2234,7 +2236,6 @@ static size_t preg_replace_func_impl(zval *return_value,
2234
2236
2235
2237
return replace_count ;
2236
2238
}
2237
- /* }}} */
2238
2239
2239
2240
static void _preg_replace_common (
2240
2241
zval * return_value ,
@@ -2392,8 +2393,8 @@ PHP_FUNCTION(preg_replace_callback)
2392
2393
Z_PARAM_LONG (flags )
2393
2394
ZEND_PARSE_PARAMETERS_END ();
2394
2395
2395
- replace_count = preg_replace_func_impl (return_value , regex_str , regex_ht ,
2396
- & fci , & fcc ,
2396
+ replace_count = php_preg_replace_func_impl (return_value , regex_str , regex_ht ,
2397
+ & fcc ,
2397
2398
subject_str , subject_ht , limit , flags );
2398
2399
if (zcount ) {
2399
2400
ZEND_TRY_ASSIGN_REF_LONG (zcount , replace_count );
@@ -2444,7 +2445,7 @@ PHP_FUNCTION(preg_replace_callback_array)
2444
2445
2445
2446
ZVAL_COPY_VALUE (& fci .function_name , replace );
2446
2447
2447
- replace_count += preg_replace_func_impl (& zv , str_idx_regex , /* regex_ht */ NULL , & fci , & fcc ,
2448
+ replace_count += php_preg_replace_func_impl (& zv , str_idx_regex , /* regex_ht */ NULL , & fcc ,
2448
2449
subject_str , subject_ht , limit , flags );
2449
2450
switch (Z_TYPE (zv )) {
2450
2451
case IS_ARRAY :
0 commit comments