]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport: fix cleanup DECREF logic in builtin_filter function.
authorGeorg Brandl <georg@python.org>
Tue, 19 Jul 2005 22:20:44 +0000 (22:20 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 19 Jul 2005 22:20:44 +0000 (22:20 +0000)
Python/bltinmodule.c

index 6fbe799f71139e9b4b27040e5488edec1f949ed0..8dd3f1cbb930f7a8d19efb36cc10fbb01ca03864 100644 (file)
@@ -147,10 +147,15 @@ builtin_filter(PyObject *self, PyObject *args)
        if (PyTuple_Check(seq))
                return filtertuple(func, seq);
 
+       /* Pre-allocate argument list tuple. */
+       arg = PyTuple_New(1);
+       if (arg == NULL)
+               return NULL;
+
        /* Get iterator. */
        it = PyObject_GetIter(seq);
        if (it == NULL)
-               return NULL;
+               goto Fail_arg;
 
        /* Guess a result list size. */
        len = PyObject_Size(seq);
@@ -159,11 +164,6 @@ builtin_filter(PyObject *self, PyObject *args)
                len = 8;        /* arbitrary */
        }
 
-       /* Pre-allocate argument list tuple. */
-       arg = PyTuple_New(1);
-       if (arg == NULL)
-               goto Fail_arg;
-
        /* Get a result list. */
        if (PyList_Check(seq) && seq->ob_refcnt == 1) {
                /* Eww - can modify the list in-place. */