Skip to content

Commit

Permalink
gh-96821: Fix undefined behaviour in _testcapimodule.c (GH-96915) (G…
Browse files Browse the repository at this point in the history
…H-96927)

* gh-96821: Assert for demonstrating undefined behaviour

* Fix UB

(cherry picked from commit cbdeda8)

Co-authored-by: C.A.M. Gerlach <[email protected]>
Co-authored-by: Matthias Görgens <[email protected]>
  • Loading branch information
3 people authored and pablogsal committed Oct 22, 2022
1 parent bac61bc commit 9e008fe
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 9e008fe

Please sign in to comment.