]> 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:39 +0000 (12:55 -0700)
committerGitHub <noreply@github.com>
Sun, 15 Mar 2020 19:55:39 +0000 (12:55 -0700)
(cherry picked from commit c81609e44eed641d3b8a137daa31ef35501c1f85)

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

index fc2d2742dd2ca69adf3b96c39565c624d637e6a4..bd580946b7eb9992ecb568a3034d057552c57c72 100644 (file)
@@ -719,8 +719,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);