summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2012-09-11 12:03:25 (GMT)
committerChristian Heimes <christian@cheimes.de>2012-09-11 12:03:25 (GMT)
commit5f520f4fed072561c5782e505284c63093b5b20d (patch)
tree2ca8cdcf4b4b5f5060dedf86d12b9b38c2275ea2 /Objects
parente4eee73293621dd7cbf172a8f6d41a1629dd9307 (diff)
downloadcpython-5f520f4fed072561c5782e505284c63093b5b20d.zip
cpython-5f520f4fed072561c5782e505284c63093b5b20d.tar.gz
cpython-5f520f4fed072561c5782e505284c63093b5b20d.tar.bz2
Issue #15900: Fixed reference leak in PyUnicode_TranslateCharmap()
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 2d74d1c..61f743e 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