From c4417cc2b187916cbb91742074775564946544ab Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 12 Jun 2024 15:27:07 +0200 Subject: [PATCH] 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 42b25dd61ff3593795c4cc2ffe876ab766098b24) Co-authored-by: Victor Stinner --- Modules/_sre/sre.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/_sre/sre.c b/Modules/_sre/sre.c index 8ef35d0658c703..6d9843bb76d791 100644 --- a/Modules/_sre/sre.c +++ b/Modules/_sre/sre.c @@ -2167,6 +2167,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; }