From e7a0d3997846155e1a9dcd95eb559039da34ee08 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 12 Jul 2007 07:53:00 +0000 Subject: [PATCH] Fixed a refcount leak in _PyUnicode_AsDefaultEncodedString(). Found by Amaury Forgeot d'Arc, SF# 1752317. (Also removed a redundant check for !errors.) --- Objects/unicodeobject.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 47b1d6c7960..2728f1f6493 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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; }