diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-09-19 11:48:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-19 11:48:58 (GMT) |
commit | 3bf8e0f487978b2c7396592816558ca852f846a1 (patch) | |
tree | d0eebba6b43d68cfadbeb48b1e2a0f0ef03502d7 /Modules | |
parent | 8e2bda8227e80444f9f3a1fe4e24d2d5f4f89385 (diff) | |
download | cpython-3bf8e0f487978b2c7396592816558ca852f846a1.zip cpython-3bf8e0f487978b2c7396592816558ca852f846a1.tar.gz cpython-3bf8e0f487978b2c7396592816558ca852f846a1.tar.bz2 |
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 cbdeda8ce7a3543cb3376d70e4cd46fcf24f42a7)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Matthias Görgens <matthias.goergens@gmail.com>
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 1a3cbe0..43fec81 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -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); } |