[Pcre-svn] [399] code/trunk: Further fix to auto-callout wit…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [399] code/trunk: Further fix to auto-callout with conditional groups whose condition is an
Revision: 399
          http://vcs.pcre.org/viewvc?view=rev&revision=399
Author:   ph10
Date:     2009-03-21 12:34:15 +0000 (Sat, 21 Mar 2009)


Log Message:
-----------
Further fix to auto-callout with conditional groups whose condition is an
assertion.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_exec.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2009-03-20 20:41:29 UTC (rev 398)
+++ code/trunk/ChangeLog    2009-03-21 12:34:15 UTC (rev 399)
@@ -42,8 +42,9 @@
     correctly handled. The rule now is that both the assertion and what follows
     in the first alternative must satisfy the test.


-9.  If auto-callout was enabled in a pattern with a conditional group, PCRE
-    could crash during matching, both with pcre_exec() and pcre_dfa_exec().
+9.  If auto-callout was enabled in a pattern with a conditional group whose 
+    condition was an assertion, PCRE could crash during matching, both with
+    pcre_exec() and pcre_dfa_exec().


 10. The PCRE_DOLLAR_ENDONLY option was not working when pcre_dfa_exec() was
     used for matching.


Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2009-03-20 20:41:29 UTC (rev 398)
+++ code/trunk/pcre_exec.c    2009-03-21 12:34:15 UTC (rev 399)
@@ -561,6 +561,8 @@
 uschar occhars[8];
 #endif


+int codelink;
+int condcode;
int ctype;
int length;
int max;
@@ -787,6 +789,8 @@

     case OP_COND:
     case OP_SCOND:
+    codelink= GET(ecode, 1);
+      
     /* Because of the way auto-callout works during compile, a callout item is
     inserted between OP_COND and an assertion condition. */


@@ -813,9 +817,11 @@
       ecode += _pcre_OP_lengths[OP_CALLOUT];
       }


+    condcode = ecode[LINK_SIZE+1];
+     
     /* Now see what the actual condition is */


-    if (ecode[LINK_SIZE+1] == OP_RREF)         /* Recursion test */
+    if (condcode == OP_RREF)         /* Recursion test */
       {
       offset = GET2(ecode, LINK_SIZE + 2);     /* Recursion group number*/
       condition = md->recursive != NULL &&
@@ -823,14 +829,14 @@
       ecode += condition? 3 : GET(ecode, 1);
       }


-    else if (ecode[LINK_SIZE+1] == OP_CREF)    /* Group used test */
+    else if (condcode == OP_CREF)    /* Group used test */
       {
       offset = GET2(ecode, LINK_SIZE+2) << 1;  /* Doubled ref number */
       condition = offset < offset_top && md->offset_vector[offset] >= 0;
       ecode += condition? 3 : GET(ecode, 1);
       }


-    else if (ecode[LINK_SIZE+1] == OP_DEF)     /* DEFINE - always false */
+    else if (condcode == OP_DEF)     /* DEFINE - always false */
       {
       condition = FALSE;
       ecode += GET(ecode, 1);
@@ -857,7 +863,7 @@
       else
         {
         condition = FALSE;
-        ecode += GET(ecode, 1);
+        ecode += codelink;
         }
       }



Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2009-03-20 20:41:29 UTC (rev 398)
+++ code/trunk/testdata/testinput2    2009-03-21 12:34:15 UTC (rev 399)
@@ -2749,4 +2749,10 @@
   abcxypqr  
   abcxypqr\Y  


+/^"((?(?=[a])[^"])|b)*"$/C
+    "ab"
+
+/^"((?(?=[a])[^"])|b)*"$/
+    "ab"
+
 / End of testinput2 /


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2009-03-20 20:41:29 UTC (rev 398)
+++ code/trunk/testdata/testoutput2    2009-03-21 12:34:15 UTC (rev 399)
@@ -9653,6 +9653,8 @@
  +7 ^ ^     b
  +7 ^^      b
  +7 ^       b
++12 ^       )
++13 ^       
  0: 
    abc 
 --->abc
@@ -9751,4 +9753,37 @@
  +0         ^    x
 No match


+/^"((?(?=[a])[^"])|b)*"$/C
+    "ab"
+--->"ab"
+ +0 ^        ^
+ +1 ^        "
+ +2 ^^       ((?(?=[a])[^"])|b)*
+ +3 ^^       (?(?=[a])[^"])
+ +5 ^^       (?=[a])
+ +8 ^^       [a]
++11 ^ ^      )
++12 ^^       [^"]
++16 ^ ^      )
++17 ^ ^      |
+ +3 ^ ^      (?(?=[a])[^"])
+ +5 ^ ^      (?=[a])
+ +8 ^ ^      [a]
++21 ^ ^      "
++18 ^ ^      b
++19 ^  ^     )
+ +3 ^  ^     (?(?=[a])[^"])
+ +5 ^  ^     (?=[a])
+ +8 ^  ^     [a]
++21 ^  ^     "
++22 ^   ^    $
++23 ^   ^    
+ 0: "ab"
+ 1: 
+
+/^"((?(?=[a])[^"])|b)*"$/
+    "ab"
+ 0: "ab"
+ 1: 
+
 / End of testinput2 /