]> granicus.if.org Git - python/commitdiff
Fixed a refcount leak in _PyUnicode_AsDefaultEncodedString().
authorGuido van Rossum <guido@python.org>
Thu, 12 Jul 2007 07:53:00 +0000 (07:53 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 12 Jul 2007 07:53:00 +0000 (07:53 +0000)
Found by Amaury Forgeot d'Arc, SF# 1752317.
(Also removed a redundant check for !errors.)

Objects/unicodeobject.c

index 47b1d6c7960a4a013646c43302bc096cbd5b7d47..2728f1f64937ef642fba59b2bc700e031ec5a3b8 100644 (file)
@@ -1206,10 +1206,7 @@ PyObject *_PyUnicode_AsDefaultEncodedString(PyObject *unicode,
     v = PyString_FromStringAndSize(PyBytes_AsString(b),
                                    PyBytes_Size(b));
     Py_DECREF(b);
-    if (!errors) {
-        Py_XINCREF(v);
-        ((PyUnicodeObject *)unicode)->defenc = v;
-    }
+    ((PyUnicodeObject *)unicode)->defenc = v;
     return v;
 }