-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-120155: Add assertion to sre.c match_getindex() #120402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
@serhiy-storchaka @sobolevn: Would you mind to review this change? I'm not sure that it's enough to fix static analyzers, but it helps me at least to detect that it's a false positive :-) |
cc @stratakis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if SIZEOF_SIZE_T > 4
# define SRE_MAXGROUPS ((SRE_CODE)INT32_MAX / 2)
#else
# define SRE_MAXGROUPS ((SRE_CODE)PY_SSIZE_T_MAX / SIZEOF_VOID_P / 2)
Definion of SRE_MAXGROUPS
^^^
It looks like that i
cannot be realistically bigger than SRE_MAXGROUPS
👍
_validate_outer() checks that |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
GH-120409 is a backport of this pull request to the 3.13 branch. |
GH-120410 is a backport of this pull request to the 3.12 branch. |
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
Add an assertion to help static analyzers to detect that i*2 cannot overflow.
Example of Coverity issue on Python 3.12.2: