@@ -545,7 +545,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
545
545
size_t pattern_len ;
546
546
uint32_t poptions = 0 ;
547
547
const uint8_t * tables = NULL ;
548
- uint8_t save_tables = 0 ;
549
548
zval * zv ;
550
549
pcre_cache_entry new_entry ;
551
550
int rc ;
@@ -718,8 +717,8 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
718
717
if (key != regex ) {
719
718
tables = (uint8_t * )zend_hash_find_ptr (& char_tables , BG (locale_string ));
720
719
if (!tables ) {
721
- save_tables = 1 ;
722
720
tables = pcre2_maketables (gctx );
721
+ zend_hash_add_ptr (& char_tables , BG (locale_string ), (void * )tables );
723
722
}
724
723
pcre2_set_character_tables (cctx , tables );
725
724
}
@@ -748,9 +747,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
748
747
php_error_docref (NULL ,E_WARNING , "Compilation failed: %s at offset %zu" , error , erroffset );
749
748
pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
750
749
efree (pattern );
751
- if (save_tables ) {
752
- pefree ((void * )tables , 1 );
753
- }
754
750
return NULL ;
755
751
}
756
752
@@ -787,11 +783,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
787
783
new_entry .preg_options = poptions ;
788
784
new_entry .compile_options = coptions ;
789
785
new_entry .extra_compile_options = extra_coptions ;
790
- #if HAVE_SETLOCALE
791
- if (save_tables ) {
792
- zend_hash_add_ptr (& char_tables , BG (locale_string ), (void * )tables );
793
- }
794
- #endif
795
786
new_entry .refcount = 0 ;
796
787
797
788
rc = pcre2_pattern_info (re , PCRE2_INFO_CAPTURECOUNT , & new_entry .capture_count );
0 commit comments