From: Pieter Eendebak Date: Wed, 4 Mar 2026 13:32:14 +0000 (+0100) Subject: gh-145376: Avoid reference leaks in failure path of _functoolsmodule.c method partial... X-Git-Tag: v3.15.0a7~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9dac4e2ebbb913479bf882f0ac582040ba54ea3;p=thirdparty%2FPython%2Fcpython.git gh-145376: Avoid reference leaks in failure path of _functoolsmodule.c method partial_new (GH-145423) --- diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 5286be0b715f..336a2e57ec01 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -252,6 +252,11 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw) } PyObject *item; PyObject *tot_args = PyTuple_New(tot_nargs); + if (tot_args == NULL) { + Py_DECREF(new_args); + Py_DECREF(pto); + return NULL; + } for (Py_ssize_t i = 0, j = 0; i < tot_nargs; i++) { if (i < npargs) { item = PyTuple_GET_ITEM(pto_args, i);