Revision: 581
http://www.exim.org/viewvc/pcre2?view=rev&revision=581
Author: ph10
Date: 2016-10-28 17:09:08 +0100 (Fri, 28 Oct 2016)
Log Message:
-----------
Fix bad memory calculation when the first branch of a lookbehind is of zero
length.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/src/pcre2_compile.c
code/trunk/testdata/testinput2
code/trunk/testdata/testoutput2
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2016-10-28 16:08:44 UTC (rev 580)
+++ code/trunk/ChangeLog 2016-10-28 16:09:08 UTC (rev 581)
@@ -29,6 +29,9 @@
existing subpattern.
(e) A conditional recursion test such as (?(R)...) misbehaved if there was a
group whose name began with "R".
+ (f) The amount of memory needed for a compiled pattern was miscalculated if a
+ lookbehind contained more than one toplevel branch and the first branch
+ was of length zero.
One effect of the refactoring is that some error numbers and messages have
changed, and the pattern offset given for compiling errors is not always the
Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c 2016-10-28 16:08:44 UTC (rev 580)
+++ code/trunk/src/pcre2_compile.c 2016-10-28 16:09:08 UTC (rev 581)
@@ -7584,11 +7584,12 @@
PUT(code, 1, (int)(code - last_branch));
bc.current_branch = last_branch = code;
code += 1 + LINK_SIZE;
- lookbehindlength = META_DATA(*pptr);
}
- /* Advance past the vertical bar */
+ /* Set the lookbehind length (if not in a lookbehind the value will be zero)
+ and then advance past the vertical bar. */
+ lookbehindlength = META_DATA(*pptr);
pptr++;
}
/* Control never reaches here */
Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2 2016-10-28 16:08:44 UTC (rev 580)
+++ code/trunk/testdata/testinput2 2016-10-28 16:09:08 UTC (rev 581)
@@ -4896,4 +4896,8 @@
/()(?<=(?0))/
+/(?<!|!(?<!))/
+
+/(?<!|!|!||||||(?<!)||(?<!)!|!||(?<!)!|!(?<!)!|!|!|!||||!!|<!)!|!||||!|/
+
# End of testinput2
Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2 2016-10-28 16:08:44 UTC (rev 580)
+++ code/trunk/testdata/testoutput2 2016-10-28 16:09:08 UTC (rev 581)
@@ -15341,6 +15341,10 @@
/()(?<=(?0))/
Failed: error 125 at offset 2: lookbehind assertion is not fixed length
+/(?<!|!(?<!))/
+
+/(?<!|!|!||||||(?<!)||(?<!)!|!||(?<!)!|!(?<!)!|!|!|!||||!!|<!)!|!||||!|/
+
# End of testinput2
Error -63: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data