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