Skip to content

Commit

Permalink
pythongh-96821: Fix undefined behaviour in _testcapimodule.c (pytho…
Browse files Browse the repository at this point in the history
…nGH-96915)

* pythongh-96821: Assert for demonstrating undefined behaviour

* Fix UB

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
(cherry picked from commit cbdeda8)

Co-authored-by: Matthias Görgens <matthias.goergens@gmail.com>
  • Loading branch information
matthiasgoergens authored and miss-islington committed Sep 19, 2022
1 parent 8e2bda8 commit 3eb6a15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix undefined behaviour in ``_testcapimodule.c``.
4 changes: 3 additions & 1 deletion Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5576,8 +5576,10 @@ meth_fastcall_keywords(PyObject* self, PyObject* const* args,
if (pyargs == NULL) {
return NULL;
}
assert(args != NULL || nargs == 0);
PyObject* const* args_offset = args == NULL ? NULL : args + nargs;
PyObject *pykwargs = PyObject_Vectorcall((PyObject*)&PyDict_Type,
args + nargs, 0, kwargs);
args_offset, 0, kwargs);
return Py_BuildValue("NNN", _null_to_none(self), pyargs, pykwargs);
}

Expand Down

0 comments on commit 3eb6a15

Please sign in to comment.