Revision: 504
http://vcs.pcre.org/viewvc?view=rev&revision=504
Author: ph10
Date: 2010-03-08 08:57:04 +0000 (Mon, 08 Mar 2010)
Log Message:
-----------
Previous patch for fixing problem with recursion loop checking was incorrect.
Modified Paths:
--------------
code/trunk/pcre_compile.c
code/trunk/testdata/testinput2
code/trunk/testdata/testoutput2
Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c 2010-03-07 17:35:52 UTC (rev 503)
+++ code/trunk/pcre_compile.c 2010-03-08 08:57:04 UTC (rev 504)
@@ -1828,14 +1828,20 @@
if (c == OP_RECURSE)
{
+ BOOL empty_branch = FALSE;
const uschar *scode = cd->start_code + GET(code, 1);
if (GET(scode, 1) == 0) return TRUE; /* Unclosed */
do
{
- if (!could_be_empty_branch(scode, endcode, utf8, cd)) return FALSE;
+ if (could_be_empty_branch(scode, endcode, utf8, cd))
+ {
+ empty_branch = TRUE;
+ break;
+ }
scode += GET(scode, 1);
}
while (*scode == OP_ALT);
+ if (!empty_branch) return FALSE; /* All branches are non-empty */
continue;
}
Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2 2010-03-07 17:35:52 UTC (rev 503)
+++ code/trunk/testdata/testinput2 2010-03-08 08:57:04 UTC (rev 504)
@@ -3230,4 +3230,6 @@
/----------------------/
+/(?P<L1>(?P<L2>0|)|(?P>L2)(?P>L1))/
+
/-- End of testinput2 --/
Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2 2010-03-07 17:35:52 UTC (rev 503)
+++ code/trunk/testdata/testoutput2 2010-03-08 08:57:04 UTC (rev 504)
@@ -10665,4 +10665,7 @@
/----------------------/
+/(?P<L1>(?P<L2>0|)|(?P>L2)(?P>L1))/
+Failed: recursive call could loop indefinitely at offset 31
+
/-- End of testinput2 --/