diff Objects/unicodeobject.c @ 42208:ca3cfb34e3c2

Fixed a refcount leak in _PyUnicode_AsDefaultEncodedString(). Found by Amaury Forgeot d'Arc, SF# 1752317. (Also removed a redundant check for !errors.)
author Guido van Rossum <guido@python.org>
date Thu, 12 Jul 2007 07:53:00 +0000
parents bf5d04e0da4c
children 18e5ae91bd29
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Thu Jul 12 07:44:15 2007 +0000
+++ b/Objects/unicodeobject.c	Thu Jul 12 07:53:00 2007 +0000
@@ -1206,10 +1206,7 @@
     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;
 }