From 0943b7909a1ddeeae8e0e1e0652f1cf55d6398cc Mon Sep 17 00:00:00 2001 From: Andrei Zmievski Date: Tue, 24 May 2005 21:12:16 +0000 Subject: [PATCH] MFH (pcre cache flush) --- ext/pcre/php_pcre.c | 16 ++++++++++++---- 1 file 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 } -- 2.50.1