[Pcre-svn] [1576] code/trunk: Fix bad compile of possessivel…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1576] code/trunk: Fix bad compile of possessively repeated conditional group that could match an
Revision: 1576
          http://vcs.pcre.org/viewvc?view=rev&revision=1576
Author:   ph10
Date:     2015-07-17 16:15:18 +0100 (Fri, 17 Jul 2015)
Log Message:
-----------
Fix bad compile of possessively repeated conditional group that could match an 
empty string.


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


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2015-07-03 07:04:10 UTC (rev 1575)
+++ code/trunk/ChangeLog    2015-07-17 15:15:18 UTC (rev 1576)
@@ -78,7 +78,10 @@
 19. JIT should return with error when the compiled pattern requires more stack
     space than the maximum.


+20. A possessively repeated conditional group that could match an empty string,
+    for example, /(?(R))*+/, was incorrectly compiled.


+
Version 8.37 28-April-2015
--------------------------


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2015-07-03 07:04:10 UTC (rev 1575)
+++ code/trunk/pcre_compile.c    2015-07-17 15:15:18 UTC (rev 1576)
@@ -6297,7 +6297,7 @@
               memmove(bracode + 1 + LINK_SIZE, bracode, IN_UCHARS(nlen));
               code += 1 + LINK_SIZE;
               nlen += 1 + LINK_SIZE;
-              *bracode = OP_BRAPOS;
+              *bracode = (*bracode == OP_COND)? OP_BRAPOS : OP_SBRAPOS;
               *code++ = OP_KETRPOS;
               PUTINC(code, 0, nlen);
               PUT(bracode, 1, nlen);


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2015-07-03 07:04:10 UTC (rev 1575)
+++ code/trunk/testdata/testinput2    2015-07-17 15:15:18 UTC (rev 1576)
@@ -4182,4 +4182,6 @@


/(?=di(?<=(?1))|(?=(.))))/

+/(?(R))*+/BZ
+
/-- End of testinput2 --/

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2015-07-03 07:04:10 UTC (rev 1575)
+++ code/trunk/testdata/testoutput2    2015-07-17 15:15:18 UTC (rev 1576)
@@ -14489,4 +14489,17 @@
 /(?=di(?<=(?1))|(?=(.))))/
 Failed: unmatched parentheses at offset 23


+/(?(R))*+/BZ
+------------------------------------------------------------------
+        Bra
+        Braposzero
+        SBraPos
+        SCond
+        Cond recurse any
+        Ket
+        KetRpos
+        Ket
+        End
+------------------------------------------------------------------
+
 /-- End of testinput2 --/