]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#1479: Fix refleak in csv module (from rev 59062).
authorGeorg Brandl <georg@python.org>
Sun, 25 Nov 2007 00:52:21 +0000 (00:52 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 25 Nov 2007 00:52:21 +0000 (00:52 +0000)
Modules/_csv.c

index 75cafb26085b024ef145725b70c5efb8ff32a12c..afa7810b566b02d0c5802186635645c39e3475e5 100644 (file)
@@ -793,14 +793,13 @@ Reader_iternext(ReaderObj *self)
                                             "newline inside string");
                         return NULL;
                 }
-               if (!PyUnicode_Check(lineobj))
-               {
-                       PyErr_Format(error_obj,
-                                    "Iterator should return strings, "
-                                    "not %.200s "
-                                    "(did you open the file in text mode?)",
+               if (!PyUnicode_Check(lineobj)) {
+                       PyErr_Format(error_obj, "iterator should return "
+                                    "strings, not %.200s (did you open "
+                                    "the file in text mode?)",
                                     lineobj->ob_type->tp_name
                                );
+                       Py_DECREF(lineobj);
                        return NULL;
                }
                 ++self->line_num;