Skip to content
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

bpo-36127: Fix compiler warning in _PyArg_UnpackKeywords(). #12353

Merged
merged 1 commit into from
Mar 16, 2019

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Mar 15, 2019

Since nargs <= maxpos, nargs can be casted to int without lost.

https://bugs.python.org/issue36127

@@ -2422,7 +2422,7 @@ _PyArg_UnpackKeywords(PyObject *const *args, Py_ssize_t nargs,
}

/* copy keyword args using kwtuple to drive process */
for (i = Py_MAX(nargs, posonly); i < maxargs; i++) {
for (i = Py_MAX((int)nargs, posonly); i < maxargs; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this code is safe is nargs > INT_MAX. (int)(INT_MAX+1) gives 0, no?

Maybe write something like:

i = (nargs < INT_MAX) ? (int)nargs : INT_MAX;
i = Py_MAX(i, posonly);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants