summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-12-20 19:29:45 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-12-20 19:29:45 (GMT)
commit53aa1d7c5756eda92bd3276dd38dfa1f0c4bcee2 (patch)
tree1a7881dd41e7aa655dccaeb08338da6a29d4ec1c /Objects
parent0f1e3ac897294213c65b58577501c4f2c169d482 (diff)
downloadcpython-53aa1d7c5756eda92bd3276dd38dfa1f0c4bcee2.zip
cpython-53aa1d7c5756eda92bd3276dd38dfa1f0c4bcee2.tar.gz
cpython-53aa1d7c5756eda92bd3276dd38dfa1f0c4bcee2.tar.bz2
fix possible if unlikely leak
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index d13c547..c4cfe1b 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8888,9 +8888,13 @@ unicode_maketrans(PyUnicodeObject *null, PyObject *args)
/* create entries for translating chars in x to those in y */
for (i = 0; i < PyUnicode_GET_SIZE(x); i++) {
key = PyLong_FromLong(PyUnicode_AS_UNICODE(x)[i]);
+ if (!key)
+ goto err;
value = PyLong_FromLong(PyUnicode_AS_UNICODE(y)[i]);
- if (!key || !value)
+ if (!value) {
+ Py_DECREF(key);
goto err;
+ }
res = PyDict_SetItem(new, key, value);
Py_DECREF(key);
Py_DECREF(value);