From ae51e4f70bea80fd704f57046e975f7e36b068ea Mon Sep 17 00:00:00 2001 From: Hai Shi Date: Sun, 15 Mar 2020 22:09:15 +0800 Subject: [PATCH] fix possible refleaks in tupleobject.c --- Objects/tupleobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 14ab53fca22705..839667ad6f1730 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -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);