Skip to content

Commit cbdeda8

Browse files
gh-96821: Fix undefined behaviour in _testcapimodule.c (GH-96915)
* gh-96821: Assert for demonstrating undefined behaviour * Fix UB Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent bbc24b2 commit cbdeda8

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
@@ -4918,8 +4918,10 @@ meth_fastcall_keywords(PyObject* self, PyObject* const* args,
49184918
if (pyargs == NULL) {
49194919
return NULL;
49204920
}
4921+
assert(args != NULL || nargs == 0);
4922+
PyObject* const* args_offset = args == NULL ? NULL : args + nargs;
49214923
PyObject *pykwargs = PyObject_Vectorcall((PyObject*)&PyDict_Type,
4922-
args + nargs, 0, kwargs);
4924+
args_offset, 0, kwargs);
49234925
return Py_BuildValue("NNN", _null_to_none(self), pyargs, pykwargs);
49244926
}
49254927

0 commit comments

Comments
 (0)