andrei Tue May 24 17:07:32 2005 EDT
Modified files:
/php-src/ext/pcre php_pcre.c
Log:
Flush regexp cache if we detect corruption.
http://cvs.php.net/diff.php/php-src/ext/pcre/php_pcre.c?r1=1.165&r2=1.166&ty=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.165 php-src/ext/pcre/php_pcre.c:1.166
--- php-src/ext/pcre/php_pcre.c:1.165 Sat Mar 12 07:03:49 2005
+++ php-src/ext/pcre/php_pcre.c Tue May 24 17:07:32 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcre.c,v 1.165 2005/03/12 12:03:49 andrey Exp $ */
+/* $Id: php_pcre.c,v 1.166 2005/05/24 21:07:32 andrei Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -161,14 +161,22 @@
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
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php