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