Skip to content

Commit

Permalink
fix possible if unlikely leak
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminp committed Dec 20, 2011
1 parent 0f1e3ac commit 53aa1d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 53aa1d7

Please sign in to comment.