Skip to content

Commit 3bf8e0f

Browse files
miss-islingtonCAM-Gerlachmatthiasgoergens
authored
gh-96821: Fix undefined behaviour in _testcapimodule.c (GH-96915) (GH-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]>
1 parent 8e2bda8 commit 3bf8e0f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix undefined behaviour in ``_testcapimodule.c``.

Modules/_testcapimodule.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -5576,8 +5576,10 @@ meth_fastcall_keywords(PyObject* self, PyObject* const* args,
55765576
if (pyargs == NULL) {
55775577
return NULL;
55785578
}
5579+
assert(args != NULL || nargs == 0);
5580+
PyObject* const* args_offset = args == NULL ? NULL : args + nargs;
55795581
PyObject *pykwargs = PyObject_Vectorcall((PyObject*)&PyDict_Type,
5580-
args + nargs, 0, kwargs);
5582+
args_offset, 0, kwargs);
55815583
return Py_BuildValue("NNN", _null_to_none(self), pyargs, pykwargs);
55825584
}
55835585

0 commit comments

Comments
 (0)