Fixed a refcount leak in _PyUnicode_AsDefaultEncodedString().

Found by Amaury Forgeot d'Arc, SF# 1752317.
(Also removed a redundant check for !errors.)
This commit is contained in:
Guido van Rossum 2007-07-12 07:53:00 +00:00
parent dc09715d0b
commit e7a0d39978

View 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;
}