summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r--ext/pcre/php_pcre.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index da7f15427a..5e404b0ddf 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -161,14 +161,22 @@ PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *pr
back the compiled pattern, otherwise go on and compile it. */
regex_len = strlen(regex);
if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {
+ /*
+ * We use a quick pcre_info() check to see whether cache is corrupted, and if it
+ * is, we flush it and compile the pattern from scratch.
+ */
+ if (pcre_info(pce->re, NULL, NULL) == PCRE_ERROR_BADMAGIC) {
+ zend_hash_clean(&PCRE_G(pcre_cache));
+ } else {
#if HAVE_SETLOCALE
- if (!strcmp(pce->locale, locale)) {
+ if (!strcmp(pce->locale, locale)) {
#endif
- *extra = pce->extra;
- *preg_options = pce->preg_options;
- *compile_options = pce->compile_options;
- return pce->re;
+ *extra = pce->extra;
+ *preg_options = pce->preg_options;
+ *compile_options = pce->compile_options;
+ return pce->re;
#if HAVE_SETLOCALE
+ }
}
#endif
}