]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix a possible refleak in tupleobject.c (GH-19018)
authorHai Shi <shihai1992@gmail.com>
Sun, 15 Mar 2020 19:37:49 +0000 (03:37 +0800)
committerGitHub <noreply@github.com>
Sun, 15 Mar 2020 19:37:49 +0000 (19:37 +0000)
Objects/tupleobject.c

index 14ab53fca22705976639f364d9cfe6ebb9d8a04d..839667ad6f1730c6d123cbd95d9e0ce1e7d5b831 100644 (file)
@@ -737,8 +737,10 @@ tuple_subtype_new(PyTypeObject *type, PyObject *iterable)
         return NULL;
     assert(PyTuple_Check(tmp));
     newobj = type->tp_alloc(type, n = PyTuple_GET_SIZE(tmp));
-    if (newobj == NULL)
+    if (newobj == NULL) {
+        Py_DECREF(tmp);
         return NULL;
+    }
     for (i = 0; i < n; i++) {
         item = PyTuple_GET_ITEM(tmp, i);
         Py_INCREF(item);