summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-06-22 15:13:29 +0200
committerAnatol Belski <ab@php.net>2018-06-22 15:18:39 +0200
commit8b58b2aac696755fb15e17ee4861411ef8e346bc (patch)
tree7b2859bc58fc045591f894bae8ed49f2b0344e67 /ext/pcre/php_pcre.c
parent3b9ecb2d65c0d68f18c37b500cedd0440c08fe96 (diff)
downloadphp-git-8b58b2aac696755fb15e17ee4861411ef8e346bc.tar.gz
Don't discard char tables just generated
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r--ext/pcre/php_pcre.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 36dda6deb5..48705d2a63 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -545,7 +545,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
size_t pattern_len;
uint32_t poptions = 0;
const uint8_t *tables = NULL;
- uint8_t save_tables = 0;
zval *zv;
pcre_cache_entry new_entry;
int rc;
@@ -718,8 +717,8 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
if (key != regex) {
tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(locale_string));
if (!tables) {
- save_tables = 1;
tables = pcre2_maketables(gctx);
+ zend_hash_add_ptr(&char_tables, BG(locale_string), (void *)tables);
}
pcre2_set_character_tables(cctx, tables);
}
@@ -748,9 +747,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
php_error_docref(NULL,E_WARNING, "Compilation failed: %s at offset %zu", error, erroffset);
pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
efree(pattern);
- if (save_tables) {
- pefree((void*)tables, 1);
- }
return NULL;
}
@@ -787,11 +783,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
new_entry.preg_options = poptions;
new_entry.compile_options = coptions;
new_entry.extra_compile_options = extra_coptions;
-#if HAVE_SETLOCALE
- if (save_tables) {
- zend_hash_add_ptr(&char_tables, BG(locale_string), (void *)tables);
- }
-#endif
new_entry.refcount = 0;
rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &new_entry.capture_count);