@@ -405,6 +405,7 @@ PHP_FUNCTION(mb_regex_encoding)
405
405
static void
406
406
_php_mb_regex_ereg_exec (INTERNAL_FUNCTION_PARAMETERS , int icase )
407
407
{
408
+ zval tmp ;
408
409
zval * arg_pattern , * array ;
409
410
char * string ;
410
411
int string_len ;
@@ -427,10 +428,13 @@ _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
427
428
/* compile the regular expression from the supplied regex */
428
429
if (Z_TYPE_P (arg_pattern ) != IS_STRING ) {
429
430
/* we convert numbers to integers and treat them as a string */
430
- if (Z_TYPE_P (arg_pattern ) == IS_DOUBLE ) {
431
- convert_to_long_ex (& arg_pattern ); /* get rid of decimal places */
431
+ tmp = * arg_pattern ;
432
+ zval_copy_ctor (& tmp );
433
+ if (Z_TYPE_P (& tmp ) == IS_DOUBLE ) {
434
+ convert_to_long (& tmp ); /* get rid of decimal places */
432
435
}
433
- convert_to_string_ex (& arg_pattern );
436
+ convert_to_string (& tmp );
437
+ arg_pattern = & tmp ;
434
438
/* don't bother doing an extended regex with just a number */
435
439
}
436
440
err = php_mbregex_compile_pattern (
@@ -439,7 +443,8 @@ _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
439
443
Z_STRLEN_P (arg_pattern ),
440
444
option , MBSTRG (current_mbctype ) TSRMLS_CC );
441
445
if (err ) {
442
- RETURN_FALSE ;
446
+ RETVAL_FALSE ;
447
+ goto out ;
443
448
}
444
449
445
450
/* actually execute the regular expression */
@@ -451,7 +456,8 @@ _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
451
456
& regs );
452
457
if (err < 0 ) {
453
458
mbre_free_registers (& regs );
454
- RETURN_FALSE ;
459
+ RETVAL_FALSE ;
460
+ goto out ;
455
461
}
456
462
457
463
match_len = 1 ;
@@ -476,6 +482,10 @@ _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
476
482
match_len = 1 ;
477
483
}
478
484
RETVAL_LONG (match_len );
485
+ out :
486
+ if (arg_pattern == & tmp ) {
487
+ zval_dtor (& tmp );
488
+ }
479
489
}
480
490
481
491
/* {{{ proto int mb_ereg(string pattern, string string [, array registers])
@@ -690,25 +700,29 @@ PHP_FUNCTION(mb_eregi_replace)
690
700
split multibyte string into array by regular expression */
691
701
PHP_FUNCTION (mb_split )
692
702
{
693
- zval * arg_pat ;
703
+ char * arg_pattern ;
704
+ int arg_pattern_len ;
694
705
mb_regex_t re ;
695
706
struct mbre_registers regs = {0 , 0 , 0 , 0 };
696
707
char * string ;
697
- int n , err , string_len , pos ;
708
+ int string_len ;
709
+
710
+ int n , err , pos ;
698
711
long count = -1 ;
699
712
700
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "zs|l" , & arg_pat ,
701
- & string , & string_len , & count ) == FAILURE ) {
713
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ss|l" , & arg_pattern , & arg_pattern_len , & string , & string_len , & count ) == FAILURE ) {
702
714
RETURN_FALSE ;
703
715
}
704
716
705
- if (count == 0 ) count = 1 ;
717
+ if (count == 0 ) {
718
+ count = 1 ;
719
+ }
706
720
707
721
/* create regex pattern buffer */
708
722
err = php_mbregex_compile_pattern (
709
723
& re ,
710
- Z_STRVAL_P ( arg_pat ) ,
711
- Z_STRLEN_P ( arg_pat ) ,
724
+ arg_pattern ,
725
+ arg_pattern_len ,
712
726
MBSTRG (regex_default_options ), MBSTRG (current_mbctype ) TSRMLS_CC );
713
727
if (err ) {
714
728
RETURN_FALSE ;
0 commit comments