Skip to content

Commit

Permalink
Add limit check for brackets with alternatives
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoltan Herczeg committed Feb 29, 2024
1 parent e8db6fa commit d688fe9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pcre2_jit_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -11314,7 +11314,7 @@ if (bra == OP_BRAMINZERO)
/* Continue to the normal backtrack. */
}

if ((ket != OP_KET && bra != OP_BRAMINZERO) || bra == OP_BRAZERO)
if ((ket != OP_KET && bra != OP_BRAMINZERO) || bra == OP_BRAZERO || (has_alternatives && repeat_type != OP_EXACT))
count_match(common);

cc += 1 + LINK_SIZE;
Expand Down
1 change: 1 addition & 0 deletions src/pcre2_jit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ static struct regression_test_case regression_test_cases[] = {
{ CM, A, 0, 0, "a1277|a1377|bX487", "bx487" },
{ CM, A, 0, 0, "a1277|a1377|bx487", "bX487" },
{ 0, A, 0, 0, "(a|)b*+a", "a" },
{ 0, A, 0, 0 | F_NOMATCH, "(.|.|.|.|.)(|.|.|.|.)(.||.|.|.)(.|.||.|.)(.|.|.||.)(.|.|.|.|)(A|.|.|.|.)(.|A|.|.|.)(.|.|A|.|.)(.|.|.|A|.)(.|.|.|.|A)(B|.|.|.|.)(.|B|.|.|.)(.|.|B|.|.)(.|.|.|B|.)(.|.|.|.|B)xa", "1234567890123456ax" },

/* Greedy and non-greedy ? operators. */
{ MU, A, 0, 0, "(?:a)?a", "laab" },
Expand Down

0 comments on commit d688fe9

Please sign in to comment.