This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients belopolsky, josh.r
Date 2016-01-13.22:24:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1452723870.39.0.274687476417.issue26104@psf.upfronthosting.co.za>
In-reply-to
Content
Minor bug introduced while implementing the fix for #7830:

In the case where functools.partial is wrapping another functools.partial instance, both of them providing positional arguments, the value nargs is not freed when the tuple concatenation fails and the constructor raises an Exception/returns NULL. Only nargs has the problem (it's a slice of the args passed to the function); pargs is a borrowed reference so there is no leak there. Admittedly, the odds of failure is incredibly low, but best to fix it on principle.

Code link: https://hg.python.org/cpython/file/5a2692911a43/Modules/_functoolsmodule.c#l77

The simplest fix is to add the explicit DECREF in the error path:

        pto->args = PySequence_Concat(pargs, nargs);
        if (pto->args == NULL) {
            pto->kw = NULL;
            Py_DECREF(nargs);  // <-- New
            Py_DECREF(pto);
            return NULL;
        }

All other code paths hit a DECREF later on, no other fixes required. I'd submit a proper patch, but I'm on a new machine and I've got a lot of work to get the repos set up again.
History
Date User Action Args
2016-01-13 22:24:30josh.rsetrecipients: + josh.r, belopolsky
2016-01-13 22:24:30josh.rsetmessageid: <1452723870.39.0.274687476417.issue26104@psf.upfronthosting.co.za>
2016-01-13 22:24:30josh.rlinkissue26104 messages
2016-01-13 22:24:29josh.rcreate