@@ -2381,38 +2381,38 @@ PHP_FUNCTION(preg_replace_callback)
2381
2381
zend_long limit = -1 , flags = 0 ;
2382
2382
size_t replace_count ;
2383
2383
zend_fcall_info fci ;
2384
- zend_fcall_info_cache fcc ;
2384
+ zend_fcall_info_cache fcc = empty_fcall_info_cache ;
2385
2385
2386
2386
/* Get function parameters and do error-checking. */
2387
2387
ZEND_PARSE_PARAMETERS_START (3 , 6 )
2388
2388
Z_PARAM_ARRAY_HT_OR_STR (regex_ht , regex_str )
2389
- Z_PARAM_FUNC (fci , fcc )
2389
+ Z_PARAM_FUNC_NO_TRAMPOLINE_FREE (fci , fcc )
2390
2390
Z_PARAM_ARRAY_HT_OR_STR (subject_ht , subject_str )
2391
2391
Z_PARAM_OPTIONAL
2392
2392
Z_PARAM_LONG (limit )
2393
2393
Z_PARAM_ZVAL (zcount )
2394
2394
Z_PARAM_LONG (flags )
2395
- ZEND_PARSE_PARAMETERS_END ( );
2395
+ ZEND_PARSE_PARAMETERS_END_EX ( goto free_trampoline );
2396
2396
2397
2397
replace_count = php_preg_replace_func_impl (return_value , regex_str , regex_ht ,
2398
2398
& fcc ,
2399
2399
subject_str , subject_ht , limit , flags );
2400
2400
if (zcount ) {
2401
2401
ZEND_TRY_ASSIGN_REF_LONG (zcount , replace_count );
2402
2402
}
2403
+ free_trampoline :
2404
+ zend_release_fcall_info_cache (& fcc );
2403
2405
}
2404
2406
/* }}} */
2405
2407
2406
2408
/* {{{ Perform Perl-style regular expression replacement using replacement callback. */
2407
2409
PHP_FUNCTION (preg_replace_callback_array )
2408
2410
{
2409
- zval zv , * replace , * zcount = NULL ;
2411
+ zval * replace , * zcount = NULL ;
2410
2412
HashTable * pattern , * subject_ht ;
2411
2413
zend_string * subject_str , * str_idx_regex ;
2412
2414
zend_long limit = -1 , flags = 0 ;
2413
2415
size_t replace_count = 0 ;
2414
- zend_fcall_info fci ;
2415
- zend_fcall_info_cache fcc ;
2416
2416
2417
2417
/* Get function parameters and do error-checking. */
2418
2418
ZEND_PARSE_PARAMETERS_START (2 , 5 )
@@ -2424,40 +2424,39 @@ PHP_FUNCTION(preg_replace_callback_array)
2424
2424
Z_PARAM_LONG (flags )
2425
2425
ZEND_PARSE_PARAMETERS_END ();
2426
2426
2427
- fci .size = sizeof (fci );
2428
- fci .object = NULL ;
2429
- fci .named_params = NULL ;
2430
-
2431
2427
if (subject_ht ) {
2432
2428
GC_TRY_ADDREF (subject_ht );
2433
2429
} else {
2434
2430
GC_TRY_ADDREF (subject_str );
2435
2431
}
2436
2432
2437
2433
ZEND_HASH_FOREACH_STR_KEY_VAL (pattern , str_idx_regex , replace ) {
2438
- if (!zend_is_callable_ex (replace , NULL , 0 , NULL , & fcc , NULL )) {
2439
- zend_argument_type_error (1 , "must contain only valid callbacks" );
2440
- goto error ;
2441
- }
2442
2434
if (!str_idx_regex ) {
2443
2435
zend_argument_type_error (1 , "must contain only string patterns as keys" );
2444
2436
goto error ;
2445
2437
}
2446
2438
2447
- ZVAL_COPY_VALUE (& fci .function_name , replace );
2439
+ zend_fcall_info_cache fcc = empty_fcall_info_cache ;
2440
+ if (!zend_is_callable_ex (replace , NULL , 0 , NULL , & fcc , NULL )) {
2441
+ zend_argument_type_error (1 , "must contain only valid callbacks" );
2442
+ goto error ;
2443
+ }
2448
2444
2449
- replace_count += php_preg_replace_func_impl (& zv , str_idx_regex , /* regex_ht */ NULL , & fcc ,
2445
+ zval retval ;
2446
+ replace_count += php_preg_replace_func_impl (& retval , str_idx_regex , /* regex_ht */ NULL , & fcc ,
2450
2447
subject_str , subject_ht , limit , flags );
2451
- switch (Z_TYPE (zv )) {
2448
+ zend_release_fcall_info_cache (& fcc );
2449
+
2450
+ switch (Z_TYPE (retval )) {
2452
2451
case IS_ARRAY :
2453
2452
ZEND_ASSERT (subject_ht );
2454
2453
zend_array_release (subject_ht );
2455
- subject_ht = Z_ARR (zv );
2454
+ subject_ht = Z_ARR (retval );
2456
2455
break ;
2457
2456
case IS_STRING :
2458
2457
ZEND_ASSERT (subject_str );
2459
2458
zend_string_release (subject_str );
2460
- subject_str = Z_STR (zv );
2459
+ subject_str = Z_STR (retval );
2461
2460
break ;
2462
2461
case IS_NULL :
2463
2462
RETVAL_NULL ();
0 commit comments