summaryrefslogtreecommitdiffstats
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)
commitbdc7e69f42fbb769f96fb970c9883a9a0c953b71 (patch)
tree1c161da68f19274547326b9c2fc34a5a90496609
parent0085a2407574a4af46019bee279895bdafbd76b8 (diff)
downloadcpython-bdc7e69f42fbb769f96fb970c9883a9a0c953b71.zip
cpython-bdc7e69f42fbb769f96fb970c9883a9a0c953b71.tar.gz
cpython-bdc7e69f42fbb769f96fb970c9883a9a0c953b71.tar.bz2
Issue #15900: Fixed reference leak in PyUnicode_TranslateCharmap()
-rw-r--r--Misc/NEWS2
-rw-r--r--Objects/unicodeobject.c11
2 files changed, 7 insertions, 6 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index f82da60..bd44af5 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.3.0 Release Candidate 3?
Core and Builtins
-----------------
+- Issue #15900: Fixed reference leak in PyUnicode_TranslateCharmap().
+
- Issue #15926: Fix crash after multiple reinitializations of the interpreter.
- Issue #15895: Fix FILE pointer leak in one error branch of
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 773a9be..6d49806 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