diff options
author | Andrei Zmievski <andrei@php.net> | 2005-05-24 21:07:32 +0000 |
---|---|---|
committer | Andrei Zmievski <andrei@php.net> | 2005-05-24 21:07:32 +0000 |
commit | 79742f81a2a7db076519a3d1fa1068d3a64276ea (patch) | |
tree | 887ad6cbc8e0ebf719a2da189f7bd1841086cb10 /ext/pcre/php_pcre.c | |
parent | 309025e8c19d1f608283af73244cd9f76d78aa3f (diff) | |
download | php-git-79742f81a2a7db076519a3d1fa1068d3a64276ea.tar.gz |
Flush regexp cache if we detect corruption.
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r-- | ext/pcre/php_pcre.c | 18 |
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 } |