Fix zero-repeated assertion-as-condition bug.

This commit is contained in:
Philip.Hazel 2014-11-19 11:17:20 +00:00
parent f024446c93
commit eea35d0cab
4 changed files with 24 additions and 2 deletions

View File

@ -53,4 +53,7 @@ matched against "abcd".
8. The pcre2_substitute() function has been implemented. 8. The pcre2_substitute() function has been implemented.
9. If an assertion condition was quantified with a minimum of zero (an odd
thing to do, but it happened), SIGSEGV or other misbehaviour could occur.
**** ****

View File

@ -1401,8 +1401,11 @@ for (;;)
condition = TRUE; condition = TRUE;
/* Advance ecode past the assertion to the start of the first branch, /* Advance ecode past the assertion to the start of the first branch,
but adjust it so that the general choosing code below works. */ but adjust it so that the general choosing code below works. If the
assertion has a quantifier that allows zero repeats we must skip over
the BRAZERO. This is a lunatic thing to do, but somebody did! */
if (*ecode == OP_BRAZERO) ecode++;
ecode += GET(ecode, 1); ecode += GET(ecode, 1);
while (*ecode == OP_ALT) ecode += GET(ecode, 1); while (*ecode == OP_ALT) ecode += GET(ecode, 1);
ecode += 1 + LINK_SIZE - PRIV(OP_lengths)[condcode]; ecode += 1 + LINK_SIZE - PRIV(OP_lengths)[condcode];

6
testdata/testinput2 vendored
View File

@ -4078,4 +4078,10 @@ a random value. /Ix
# End of substitute tests # End of substitute tests
"((?=(?(?=(?(?=(?(?=())))*)))))"
a
"(?(?=)?==)(((((((((?=)))))))))"
a
# End of testinput2 # End of testinput2

10
testdata/testoutput2 vendored
View File

@ -13705,4 +13705,14 @@ Failed: error -34: bad option value
# End of substitute tests # End of substitute tests
"((?=(?(?=(?(?=(?(?=())))*)))))"
a
0:
1:
2:
"(?(?=)?==)(((((((((?=)))))))))"
a
No match
# End of testinput2 # End of testinput2