[Pcre-svn] [154] code/trunk: Fix zero-repeated assertion-as-…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [154] code/trunk: Fix zero-repeated assertion-as-condition bug.
Revision: 154
          http://www.exim.org/viewvc/pcre2?view=rev&revision=154
Author:   ph10
Date:     2014-11-19 11:17:20 +0000 (Wed, 19 Nov 2014)


Log Message:
-----------
Fix zero-repeated assertion-as-condition bug.

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


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2014-11-18 18:32:12 UTC (rev 153)
+++ code/trunk/ChangeLog    2014-11-19 11:17:20 UTC (rev 154)
@@ -53,4 +53,7 @@


8. The pcre2_substitute() function has been implemented.

+9. If an assertion condition was quantified with a minimum of zero (an odd
+thing to do, but it happened), SIGSEGV or other misbehaviour could occur.
+
****

Modified: code/trunk/src/pcre2_match.c
===================================================================
--- code/trunk/src/pcre2_match.c    2014-11-18 18:32:12 UTC (rev 153)
+++ code/trunk/src/pcre2_match.c    2014-11-19 11:17:20 UTC (rev 154)
@@ -1401,8 +1401,11 @@
         condition = TRUE;


         /* Advance ecode past the assertion to the start of the first branch,
-        but adjust it so that the general choosing code below works. */
-
+        but adjust it so that the general choosing code below works. If the 
+        assertion has a quantifier that allows zero repeats we must skip over 
+        the BRAZERO. This is a lunatic thing to do, but somebody did! */
+        
+        if (*ecode == OP_BRAZERO) ecode++; 
         ecode += GET(ecode, 1);
         while (*ecode == OP_ALT) ecode += GET(ecode, 1);
         ecode += 1 + LINK_SIZE - PRIV(OP_lengths)[condcode];


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2014-11-18 18:32:12 UTC (rev 153)
+++ code/trunk/testdata/testinput2    2014-11-19 11:17:20 UTC (rev 154)
@@ -4078,4 +4078,10 @@


# End of substitute tests

+"((?=(?(?=(?(?=(?(?=())))*)))))"
+    a
+
+"(?(?=)?==)(((((((((?=)))))))))"
+    a
+
 # End of testinput2 


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2014-11-18 18:32:12 UTC (rev 153)
+++ code/trunk/testdata/testoutput2    2014-11-19 11:17:20 UTC (rev 154)
@@ -13705,4 +13705,14 @@


# End of substitute tests

+"((?=(?(?=(?(?=(?(?=())))*)))))"
+    a
+ 0: 
+ 1: 
+ 2: 
+
+"(?(?=)?==)(((((((((?=)))))))))"
+    a
+No match
+
 # End of testinput2