Revision: 1581
http://vcs.pcre.org/viewvc?view=rev&revision=1581
Author: ph10
Date: 2015-07-22 10:06:15 +0100 (Wed, 22 Jul 2015)
Log Message:
-----------
Fix bad compilation of repeated conditional with only one branch.
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-22 06:45:12 UTC (rev 1580)
+++ code/trunk/ChangeLog 2015-07-22 09:06:15 UTC (rev 1581)
@@ -91,7 +91,11 @@
16. Pathological patterns containing many nested occurrences of [: caused
pcre_compile() to run for a very long time.
+17. A conditional group with only one branch has an implicit empty alternative
+ branch and must therefore be treated as potentially matching an empty
+ string.
+
Version 8.37 28-April-2015
--------------------------
Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c 2015-07-22 06:45:12 UTC (rev 1580)
+++ code/trunk/pcre_compile.c 2015-07-22 09:06:15 UTC (rev 1581)
@@ -6274,7 +6274,13 @@
}
while (*scode == OP_ALT);
}
+
+ /* A conditional group with only one branch has an implicit empty
+ alternative branch. */
+ if (*bracode == OP_COND && bracode[GET(bracode,1)] != OP_ALT)
+ *bracode = OP_SCOND;
+
/* Handle possessive quantifiers. */
if (possessive_quantifier)
Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2 2015-07-22 06:45:12 UTC (rev 1580)
+++ code/trunk/testdata/testinput2 2015-07-22 09:06:15 UTC (rev 1581)
@@ -4188,4 +4188,6 @@
"[[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[:::::::::::::::::[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[[[:::E[[[:[:[[:[:::[[:::E[[[:[:[[:'[:::::E[[[:[::::::[[[:[[[[[[[::E[[[:[::::::[[[:[[[[[[[[:[[::[::::[[:::::::[[:[[[[[[[:[[::[:[[:[~"
+/()(?(R)0)*+/BZ
+
/-- End of testinput2 --/
Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2 2015-07-22 06:45:12 UTC (rev 1580)
+++ code/trunk/testdata/testoutput2 2015-07-22 09:06:15 UTC (rev 1581)
@@ -14507,4 +14507,20 @@
"[[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[:::::::::::::::::[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[[[:::E[[[:[:[[:[:::[[:::E[[[:[:[[:'[:::::E[[[:[::::::[[[:[[[[[[[::E[[[:[::::::[[[:[[[[[[[[:[[::[::::[[:::::::[[:[[[[[[[:[[::[:[[:[~"
Failed: missing terminating ] for character class at offset 353
+/()(?(R)0)*+/BZ
+------------------------------------------------------------------
+ Bra
+ CBra 1
+ Ket
+ Braposzero
+ SBraPos
+ SCond
+ Cond recurse any
+ 0
+ Ket
+ KetRpos
+ Ket
+ End
+------------------------------------------------------------------
+
/-- End of testinput2 --/