Skip to content

Commit ab30934

Browse files
[3.12] gh-120155: Add assertion to sre.c match_getindex() (GH-120402) (#120410)
gh-120155: Add assertion to sre.c match_getindex() (GH-120402) Add an assertion to help static analyzers to detect that i*2 cannot overflow. (cherry picked from commit 42b25dd) Co-authored-by: Victor Stinner <[email protected]>
1 parent e8a9f0c commit ab30934

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Modules/_sre/sre.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,6 +2167,8 @@ match_getindex(MatchObject* self, PyObject* index)
21672167
return -1;
21682168
}
21692169

2170+
// Check that i*2 cannot overflow to make static analyzers happy
2171+
assert(i <= SRE_MAXGROUPS);
21702172
return i;
21712173
}
21722174

0 commit comments

Comments
 (0)