Skip to content

Commit 88a3f18

Browse files
miss-islingtonCAM-Gerlachmatthiasgoergens
authored
gh-96821: Fix undefined behaviour in _testcapimodule.c (GH-96915) (GH-96926)
* gh-96821: Assert for demonstrating undefined behaviour * Fix UB (cherry picked from commit cbdeda8) Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Matthias Görgens <matthias.goergens@gmail.com>
1 parent f4be544 commit 88a3f18

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
@@ -5475,8 +5475,10 @@ meth_fastcall_keywords(PyObject* self, PyObject* const* args,
54755475
if (pyargs == NULL) {
54765476
return NULL;
54775477
}
5478+
assert(args != NULL || nargs == 0);
5479+
PyObject* const* args_offset = args == NULL ? NULL : args + nargs;
54785480
PyObject *pykwargs = PyObject_Vectorcall((PyObject*)&PyDict_Type,
5479-
args + nargs, 0, kwargs);
5481+
args_offset, 0, kwargs);
54805482
return Py_BuildValue("NNN", _null_to_none(self), pyargs, pykwargs);
54815483
}
54825484

0 commit comments

Comments
 (0)