Skip to content

Commit 1326d2a

Browse files
gh-140979: Fix off-by-one error in the RE code validator (GH-140984)
It was too lenient and allowed MARK opcodes with too large value.
1 parent fa9c3ee commit 1326d2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/_sre/sre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
19461946
sre_match() code is robust even if they don't, and the worst
19471947
you can get is nonsensical match results. */
19481948
GET_ARG;
1949-
if (arg > 2 * (size_t)groups + 1) {
1949+
if (arg >= 2 * (size_t)groups) {
19501950
VTRACE(("arg=%d, groups=%d\n", (int)arg, (int)groups));
19511951
FAIL;
19521952
}

0 commit comments

Comments
 (0)