From: Andrei Zmievski Date: Tue, 24 May 2005 21:12:16 +0000 (+0000) Subject: MFH (pcre cache flush) X-Git-Tag: php-4.4.0RC1~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0943b7909a1ddeeae8e0e1e0652f1cf55d6398cc;p=php MFH (pcre cache flush) --- 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 }