https://github.com/python/cpython/commit/f9dac4e2ebbb913479bf882f0ac582040ba54ea3
commit: f9dac4e2ebbb913479bf882f0ac582040ba54ea3
branch: main
author: Pieter Eendebak <[email protected]>
committer: encukou <[email protected]>
date: 2026-03-04T14:32:14+01:00
summary:

gh-145376: Avoid reference leaks in failure path of _functoolsmodule.c method 
partial_new (GH-145423)

files:
M Modules/_functoolsmodule.c

diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 5286be0b715fff..336a2e57ec0179 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);

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to