Mercurial > cpython-lru_cache-weakref
diff Objects/unicodeobject.c @ 78988:4f2811e5e462
Issue #15900: Fixed reference leak in PyUnicode_TranslateCharmap()
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Tue, 11 Sep 2012 14:03:25 +0200 |
| parents | a3e194661b5f |
| children | 99112b851b25 |
line wrap: on
line diff
--- a/Objects/unicodeobject.c Tue Sep 11 03:20:22 2012 -0700 +++ b/Objects/unicodeobject.c Tue Sep 11 14:03:25 2012 +0200 @@ -8585,10 +8585,13 @@ 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 @@ 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
