From: Victor Stinner Date: Wed, 12 Jun 2024 13:27:07 +0000 (+0200) Subject: gh-120155: Add assertion to sre.c match_getindex() (#120402) X-Git-Tag: v3.14.0a1~1519 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=42b25dd61ff3593795c4cc2ffe876ab766098b24;p=thirdparty%2FPython%2Fcpython.git gh-120155: Add assertion to sre.c match_getindex() (#120402) Add an assertion to help static analyzers to detect that i*2 cannot overflow. --- diff --git a/Modules/_sre/sre.c b/Modules/_sre/sre.c index e33034086481..0c656b47991c 100644 --- a/Modules/_sre/sre.c +++ b/Modules/_sre/sre.c @@ -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; }