Commit e7a0d399 authored by Guido van Rossum's avatar Guido van Rossum

Fixed a refcount leak in _PyUnicode_AsDefaultEncodedString().

Found by Amaury Forgeot d'Arc, SF# 1752317.
(Also removed a redundant check for !errors.)
parent dc09715d
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment