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
1 changed files with 1 additions and 4 deletions

View File

@ -1206,10 +1206,7 @@ PyObject *_PyUnicode_AsDefaultEncodedString(PyObject *unicode,
v = PyString_FromStringAndSize(PyBytes_AsString(b), v = PyString_FromStringAndSize(PyBytes_AsString(b),
PyBytes_Size(b)); PyBytes_Size(b));
Py_DECREF(b); Py_DECREF(b);
if (!errors) { ((PyUnicodeObject *)unicode)->defenc = v;
Py_XINCREF(v);
((PyUnicodeObject *)unicode)->defenc = v;
}
return v; return v;
} }