gh-120155: Add assertion to sre.c match_getindex() (#120402)

Add an assertion to help static analyzers to detect that i*2 cannot
overflow.
This commit is contained in:
Victor Stinner 2024-06-12 15:27:07 +02:00 committed by GitHub
parent 4b1e85bafc
commit 42b25dd61f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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;
}