Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53aa1d7

Browse files
committed
fix possible if unlikely leak
1 parent 0f1e3ac commit 53aa1d7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Objects/unicodeobject.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8888,9 +8888,13 @@ unicode_maketrans(PyUnicodeObject *null, PyObject *args)
88888888
/* create entries for translating chars in x to those in y */
88898889
for (i = 0; i < PyUnicode_GET_SIZE(x); i++) {
88908890
key = PyLong_FromLong(PyUnicode_AS_UNICODE(x)[i]);
8891+
if (!key)
8892+
goto err;
88918893
value = PyLong_FromLong(PyUnicode_AS_UNICODE(y)[i]);
8892-
if (!key || !value)
8894+
if (!value) {
8895+
Py_DECREF(key);
88938896
goto err;
8897+
}
88948898
res = PyDict_SetItem(new, key, value);
88958899
Py_DECREF(key);
88968900
Py_DECREF(value);

0 commit comments

Comments
 (0)