]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-120155: Add assertion to sre.c match_getindex() (#120402)
authorVictor Stinner <vstinner@python.org>
Wed, 12 Jun 2024 13:27:07 +0000 (15:27 +0200)
committerGitHub <noreply@github.com>
Wed, 12 Jun 2024 13:27:07 +0000 (15:27 +0200)
Add an assertion to help static analyzers to detect that i*2 cannot
overflow.

Modules/_sre/sre.c

index e33034086481c23174cbca8dc797cab8cf3f0e64..0c656b47991c2f1c9881f25540e3a5513149bac5 100644 (file)
@@ -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;
 }