https://github.com/python/cpython/commit/e04809299fc1a5f0ff0b567173439cb0b6f8e907
commit: e04809299fc1a5f0ff0b567173439cb0b6f8e907
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2024-06-12T14:07:36Z
summary:

[3.13] gh-120155: Add assertion to sre.c match_getindex() (GH-120402) (#120409)

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 <[email protected]>

files:
M Modules/_sre/sre.c

diff --git a/Modules/_sre/sre.c b/Modules/_sre/sre.c
index e33034086481c2..0c656b47991c2f 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;
 }
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to