Skip to content

Conversation

@hyongtao-code
Copy link

@hyongtao-code hyongtao-code commented Dec 11, 2025

This PR fixes incorrect calls to PyObject_CallFunction where an extra NULL argument was passed despite the format string already specifying the complete argument list.
PyObject_CallFunction does not use a NULL terminator; it relies solely on the format string to determine how many arguments to read. Providing more arguments than required results in undefined behavior due to va_list misalignment.

The affected calls:

  • PyImport_Import() — "OOOOi" was given 6 arguments instead of 5
  • deque_copy() — "Oi" was given 3 arguments instead of 2

Both have been corrected by removing the superfluous NULL. No functional changes beyond fixing the API misuse.

This PR fixes incorrect calls to PyObject_CallFunction where an
extra NULL argument was passed despite the format string already
specifying the complete argument list.
PyObject_CallFunction does not use a NULL terminator; it relies
solely on the format string to determine how many arguments to read.
Providing more arguments than required results in undefined behavior
due to va_list misalignment.

The affected calls:
- PyImport_Import() — "OOOOi" was given 6 arguments instead of 5
- deque_copy() — "Oi" was given 3 arguments instead of 2

Both have been corrected by removing the superfluous NULL.
No functional changes beyond fixing the API misuse.

Signed-off-by: Yongtao Huang <[email protected]>
@python-cla-bot
Copy link

python-cla-bot bot commented Dec 11, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

This comment was marked as resolved.

@hyongtao-code hyongtao-code changed the title gh142606: Fix extra NULL arguments passed to PyObject_CallFunction gh-142606: Fix extra NULL arguments passed to PyObject_CallFunction Dec 11, 2025
@bedevere-app

This comment was marked as resolved.

@encukou
Copy link
Member

encukou commented Dec 12, 2025

undefined behavior due to va_list misalignment

I don't think this is undefined behaviour. Could you give an example where this breaks, or clarify where a C standard disallows unused varargs?

@encukou encukou added the pending The issue will be closed if no feedback is provided label Dec 12, 2025
@hyongtao-code
Copy link
Author

I don't think this is undefined behaviour. Could you give an example where this breaks, or clarify where a C standard disallows unused varargs?

Agree, sorry for that. Close it.

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

Labels

awaiting review pending The issue will be closed if no feedback is provided skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants