Skip to content

Commit

Permalink
pythongh-120155: Add assertion to sre.c match_getindex()
Browse files Browse the repository at this point in the history
Add an assertion to help static analyzers to detect that i*2 cannot
overflow.
  • Loading branch information
vstinner committed Jun 12, 2024
1 parent 97b69db commit 2d2c3ec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Modules/_sre/sre.c
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,8 @@ match_getindex(MatchObject* self, PyObject* index)
return -1;
}

// Check that i*2 cannot overflow to make static analyzers happy
assert(i <= SRE_MAXGROUPS);
return i;
}

Expand Down

0 comments on commit 2d2c3ec

Please sign in to comment.