summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2005-05-24 21:12:16 +0000
committerAndrei Zmievski <andrei@php.net>2005-05-24 21:12:16 +0000
commit0943b7909a1ddeeae8e0e1e0652f1cf55d6398cc (patch)
tree00ce4ed1bd6d9f774ba0e277bfc471a88e4d4783
parent630521306657766d1f12358fa7561226e47a13ea (diff)
downloadphp-git-0943b7909a1ddeeae8e0e1e0652f1cf55d6398cc.tar.gz
MFH (pcre cache flush)
-rw-r--r--ext/pcre/php_pcre.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 7eba5a639d..e25be3a320 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -152,13 +152,21 @@ PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *preg_
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;
- return pce->re;
+ *extra = pce->extra;
+ *preg_options = pce->preg_options;
+ return pce->re;
#if HAVE_SETLOCALE
+ }
}
#endif
}