]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix a possible refleak in tupleobject.c (GH-19018)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 15 Mar 2020 19:55:41 +0000 (12:55 -0700)
committerGitHub <noreply@github.com>
Sun, 15 Mar 2020 19:55:41 +0000 (12:55 -0700)
(cherry picked from commit c81609e44eed641d3b8a137daa31ef35501c1f85)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
Objects/tupleobject.c

index 7ee06e20e4a9131ed1e2820bc24b606bcd517c10..2a1b8fad98dbb08702bc7f696f8b54d2ed619bfb 100644 (file)
@@ -696,8 +696,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);