diff options
author | Matthias Görgens <matthias.goergens@gmail.com> | 2022-09-19 07:59:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-19 07:59:13 (GMT) |
commit | cbdeda8ce7a3543cb3376d70e4cd46fcf24f42a7 (patch) | |
tree | b17143d740617257acf2e1544815ec5188aaa1cf /Modules | |
parent | bbc24b2bd569108b957ed24c5a95ffeaf8cde0db (diff) | |
download | cpython-cbdeda8ce7a3543cb3376d70e4cd46fcf24f42a7.zip cpython-cbdeda8ce7a3543cb3376d70e4cd46fcf24f42a7.tar.gz cpython-cbdeda8ce7a3543cb3376d70e4cd46fcf24f42a7.tar.bz2 |
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 <CAM.Gerlach@Gerlach.CAM>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 2d4c73c..b8f71d4 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4918,8 +4918,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); } |