8000 gh-120155: Add assertion to sre.c match_getindex() (#120402) · estyxx/cpython@0fffa6c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fffa6c

Browse files
vstinnerestyxx
authored andcommitted
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 1394471 commit 0fffa6c

File tree

1 file changed

+ 8000 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
@@ -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)
0