Skip to content

Commit 8b58b2a

Browse files
committed
Don't discard char tables just generated
1 parent 3b9ecb2 commit 8b58b2a

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

ext/pcre/php_pcre.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
545545
size_t pattern_len;
546546
uint32_t poptions = 0;
547547
const uint8_t *tables = NULL;
548-
uint8_t save_tables = 0;
549548
zval *zv;
550549
pcre_cache_entry new_entry;
551550
int rc;
@@ -718,8 +717,8 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
718717
if (key != regex) {
719718
tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(locale_string));
720719
if (!tables) {
721-
save_tables = 1;
722720
tables = pcre2_maketables(gctx);
721+
zend_hash_add_ptr(&char_tables, BG(locale_string), (void *)tables);
723722
}
724723
pcre2_set_character_tables(cctx, tables);
725724
}
@@ -748,9 +747,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
748747
php_error_docref(NULL,E_WARNING, "Compilation failed: %s at offset %zu", error, erroffset);
749748
pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
750749
efree(pattern);
751-
if (save_tables) {
752-
pefree((void*)tables, 1);
753-
}
754750
return NULL;
755751
}
756752

@@ -787,11 +783,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
787783
new_entry.preg_options = poptions;
788784
new_entry.compile_options = coptions;
789785
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
795786
new_entry.refcount = 0;
796787

797788
rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &new_entry.capture_count);

0 commit comments

Comments
 (0)