Fix bad memory calculation when the first branch of a lookbehind is of zero

length.
This commit is contained in:
Philip.Hazel 2016-10-28 16:09:08 +00:00
parent e036cda7ea
commit 24ab24fde0
4 changed files with 14 additions and 2 deletions

View File

@ -29,6 +29,9 @@ some minor bugs and Perl incompatibilities were fixed, including:
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

View File

@ -7584,11 +7584,12 @@ for (;;)
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 */

4
testdata/testinput2 vendored
View File

@ -4896,4 +4896,8 @@ a)"xI
/()(?<=(?0))/
/(?<!|!(?<!))/
/(?<!|!|!||||||(?<!)||(?<!)!|!||(?<!)!|!(?<!)!|!|!|!||||!!|<!)!|!||||!|/
# End of testinput2

View File

@ -15341,6 +15341,10 @@ Subject length lower bound = 0
/()(?<=(?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