]> granicus.if.org Git - python/commitdiff
fix possible if unlikely leak
authorBenjamin Peterson <benjamin@python.org>
Tue, 20 Dec 2011 19:29:45 +0000 (13:29 -0600)
committerBenjamin Peterson <benjamin@python.org>
Tue, 20 Dec 2011 19:29:45 +0000 (13:29 -0600)
Objects/unicodeobject.c

index d13c5470b35db90bf3ec4cbf59c2b4bf7b59cbfd..c4cfe1bca05cf7a4da8838e8cea812ae77db7067 100644 (file)
@@ -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);