From: Christian Heimes Date: Tue, 11 Sep 2012 12:03:25 +0000 (+0200) Subject: Issue #15900: Fixed reference leak in PyUnicode_TranslateCharmap() X-Git-Tag: v3.3.1rc1~818^2^2~92 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f520f4fed072561c5782e505284c63093b5b20d;p=thirdparty%2FPython%2Fcpython.git Issue #15900: Fixed reference leak in PyUnicode_TranslateCharmap() --- diff --git a/Misc/NEWS b/Misc/NEWS index d1aeaec9b558..85160873f43e 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ What's New in Python 3.3.1 Core and Builtins ----------------- +- Issue #15900: Fixed reference leak in PyUnicode_TranslateCharmap(). + - Issue #15839: Convert SystemErrors in super() to RuntimeErrors. - Issue #15846: Fix SystemError which happened when using ast.parse in an diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 2d74d1cca3bb..61f743ebda60 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8585,10 +8585,13 @@ PyUnicode_TranslateCharmap(const Py_UNICODE *p, PyObject *mapping, const char *errors) { + PyObject *result; PyObject *unicode = PyUnicode_FromUnicode(p, size); if (!unicode) return NULL; - return _PyUnicode_TranslateCharmap(unicode, mapping, errors); + result = _PyUnicode_TranslateCharmap(unicode, mapping, errors); + Py_DECREF(unicode); + return result; } PyObject * @@ -8600,14 +8603,10 @@ PyUnicode_Translate(PyObject *str, str = PyUnicode_FromObject(str); if (str == NULL) - goto onError; + return NULL; result = _PyUnicode_TranslateCharmap(str, mapping, errors); Py_DECREF(str); return result; - - onError: - Py_XDECREF(str); - return NULL; } static Py_UCS4