Skip to content

Commit 42b25dd

Browse files
authored
pythongh-120155: Add assertion to sre.c match_getindex() (python#120402)
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
1 parent 4b1e85b commit 42b25dd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Modules/_sre/sre.c

+2
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,8 @@ match_getindex(MatchObject* self, PyObject* index)
22172217
return -1;
22182218
}
22192219

2220+
// Check that i*2 cannot overflow to make static analyzers happy
2221+
assert(i <= SRE_MAXGROUPS);
22202222
return i;
22212223
}
22222224

0 commit comments

Comments
 (0)