]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-145376: Avoid reference leaks in failure path of _functoolsmodule.c method partial...
authorPieter Eendebak <pieter.eendebak@gmail.com>
Wed, 4 Mar 2026 13:32:14 +0000 (14:32 +0100)
committerGitHub <noreply@github.com>
Wed, 4 Mar 2026 13:32:14 +0000 (14:32 +0100)
Modules/_functoolsmodule.c

index 5286be0b715fffc8031e9c2bc595b7e9a2954e0b..336a2e57ec0179159b2b136cde3fa1d075cdcf0e 100644 (file)
@@ -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);