andrei          Tue May 24 18:11:39 2005 EDT

  Modified files:              (Branch: PHP_5_0)
    /php-src/ext/pcre   php_pcre.c 
  Log:
  MFH
  
  
http://cvs.php.net/diff.php/php-src/ext/pcre/php_pcre.c?r1=1.157.2.3&r2=1.157.2.4&ty=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.157.2.3 
php-src/ext/pcre/php_pcre.c:1.157.2.4
--- php-src/ext/pcre/php_pcre.c:1.157.2.3       Wed Aug 25 16:48:25 2004
+++ php-src/ext/pcre/php_pcre.c Tue May 24 18:11:39 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcre.c,v 1.157.2.3 2004/08/25 20:48:25 andrei Exp $ */
+/* $Id: php_pcre.c,v 1.157.2.4 2005/05/24 22:11:39 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

Reply via email to