]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix leak in the print function.
authorGeorg Brandl <georg@python.org>
Mon, 26 Feb 2007 10:35:10 +0000 (10:35 +0000)
committerGeorg Brandl <georg@python.org>
Mon, 26 Feb 2007 10:35:10 +0000 (10:35 +0000)
Python/bltinmodule.c

index c71aed1dd7dcfdcbb2152979082b0f7204755787..78aeeb7937e144f1897b1e28b58f609ddc781d58 100644 (file)
@@ -1392,12 +1392,14 @@ static PyObject *
 builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
 {
        static char *kwlist[] = {"sep", "end", "file", 0};
-       PyObject *dummy_args = PyTuple_New(0);
+       static PyObject *dummy_args;
        PyObject *sep = NULL, *end = NULL, *file = NULL;
        int i, err;
 
-       if (dummy_args == NULL)
-               return NULL;
+       if (dummy_args == NULL) {
+               if (!(dummy_args = PyTuple_New(0)))
+                       return NULL;
+       }
        if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOO:print",
                                         kwlist, &sep, &end, &file))
                 return NULL;