@@ -612,20 +612,31 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
612
612
pcre_cache_entry * ret ;
613
613
614
614
if (locale_aware && BG (ctype_string )) {
615
- key = zend_string_concat2 (
615
+ key = zend_string_concat3 (
616
616
ZSTR_VAL (BG (ctype_string )), ZSTR_LEN (BG (ctype_string )),
617
- ZSTR_VAL (regex ), ZSTR_LEN (regex ));
617
+ ZSTR_VAL (regex ), ZSTR_LEN (regex ),
618
+ #ifdef HAVE_PCRE_JIT_SUPPORT
619
+ PCRE_G (jit ) ? "1" : "0" , 1
620
+ #else
621
+ "" , 0
622
+ #endif
623
+ );
618
624
} else {
619
- key = regex ;
625
+ key = zend_string_concat2 (
626
+ ZSTR_VAL (regex ), ZSTR_LEN (regex ),
627
+ #ifdef HAVE_PCRE_JIT_SUPPORT
628
+ PCRE_G (jit ) ? "1" : "0" , 1
629
+ #else
630
+ "" , 0
631
+ #endif
632
+ );
620
633
}
621
634
622
635
/* Try to lookup the cached regex entry, and if successful, just pass
623
636
back the compiled pattern, otherwise go on and compile it. */
624
637
zv = zend_hash_find (& PCRE_G (pcre_cache ), key );
625
638
if (zv ) {
626
- if (key != regex ) {
627
- zend_string_release_ex (key , 0 );
628
- }
639
+ zend_string_release_ex (key , 0 );
629
640
return (pcre_cache_entry * )Z_PTR_P (zv );
630
641
}
631
642
@@ -636,9 +647,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
636
647
get to the end without encountering a delimiter. */
637
648
while (isspace ((int )* (unsigned char * )p )) p ++ ;
638
649
if (p >= end_p ) {
639
- if (key != regex ) {
640
- zend_string_release_ex (key , 0 );
641
- }
650
+ zend_string_release_ex (key , 0 );
642
651
php_error_docref (NULL , E_WARNING , "Empty regular expression" );
643
652
pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
644
653
return NULL ;
@@ -648,9 +657,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
648
657
or a backslash. */
649
658
delimiter = * p ++ ;
650
659
if (isalnum ((int )* (unsigned char * )& delimiter ) || delimiter == '\\' || delimiter == '\0' ) {
651
- if (key != regex ) {
652
- zend_string_release_ex (key , 0 );
653
- }
660
+ zend_string_release_ex (key , 0 );
654
661
php_error_docref (NULL , E_WARNING , "Delimiter must not be alphanumeric, backslash, or NUL" );
655
662
pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
656
663
return NULL ;
@@ -691,9 +698,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
691
698
}
692
699
693
700
if (pp >= end_p ) {
694
- if (key != regex ) {
695
- zend_string_release_ex (key , 0 );
696
- }
701
+ zend_string_release_ex (key , 0 );
697
702
if (start_delimiter == end_delimiter ) {
698
703
php_error_docref (NULL ,E_WARNING , "No ending delimiter '%c' found" , delimiter );
699
704
} else {
@@ -753,9 +758,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
753
758
}
754
759
pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
755
760
efree (pattern );
756
- if (key != regex ) {
757
- zend_string_release_ex (key , 0 );
758
- }
761
+ zend_string_release_ex (key , 0 );
759
762
return NULL ;
760
763
}
761
764
}
@@ -764,13 +767,11 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
764
767
php_error_docref (NULL , E_WARNING , "The /e modifier is no longer supported, use preg_replace_callback instead" );
765
768
pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
766
769
efree (pattern );
767
- if (key != regex ) {
768
- zend_string_release_ex (key , 0 );
769
- }
770
+ zend_string_release_ex (key , 0 );
770
771
return NULL ;
771
772
}
772
773
773
- if (key != regex ) {
774
+ if (locale_aware && BG ( ctype_string ) ) {
774
775
tables = (uint8_t * )zend_hash_find_ptr (& char_tables , BG (ctype_string ));
775
776
if (!tables ) {
776
777
zend_string * _k ;
@@ -794,9 +795,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
794
795
re = pcre2_compile ((PCRE2_SPTR )pattern , pattern_len , coptions , & errnumber , & erroffset , cctx );
795
796
796
797
if (re == NULL ) {
797
- if (key != regex ) {
798
- zend_string_release_ex (key , 0 );
799
- }
798
+ zend_string_release_ex (key , 0 );
800
799
pcre2_get_error_message (errnumber , error , sizeof (error ));
801
800
php_error_docref (NULL ,E_WARNING , "Compilation failed: %s at offset %zu" , error , erroffset );
802
801
pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
@@ -846,19 +845,15 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
846
845
847
846
rc = pcre2_pattern_info (re , PCRE2_INFO_CAPTURECOUNT , & new_entry .capture_count );
848
847
if (rc < 0 ) {
849
- if (key != regex ) {
850
- zend_string_release_ex (key , 0 );
851
- }
848
+ zend_string_release_ex (key , 0 );
852
849
php_error_docref (NULL , E_WARNING , "Internal pcre2_pattern_info() error %d" , rc );
853
850
pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
854
851
return NULL ;
855
852
}
856
853
857
854
rc = pcre2_pattern_info (re , PCRE2_INFO_NAMECOUNT , & new_entry .name_count );
858
855
if (rc < 0 ) {
859
- if (key != regex ) {
860
- zend_string_release_ex (key , 0 );
861
- }
856
+ zend_string_release_ex (key , 0 );
862
857
php_error_docref (NULL , E_WARNING , "Internal pcre_pattern_info() error %d" , rc );
863
858
pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
864
859
return NULL ;
@@ -882,9 +877,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
882
877
ret = zend_hash_add_new_mem (& PCRE_G (pcre_cache ), key , & new_entry , sizeof (pcre_cache_entry ));
883
878
}
884
879
885
- if (key != regex ) {
886
- zend_string_release_ex (key , 0 );
887
- }
880
+ zend_string_release_ex (key , 0 );
888
881
889
882
return ret ;
890
883
}
0 commit comments