From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sun, 15 Mar 2020 19:55:39 +0000 (-0700) Subject: Fix a possible refleak in tupleobject.c (GH-19018) X-Git-Tag: v3.8.3rc1~94 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=890dcfe4035888f70207eaac05662d6e29606214;p=thirdparty%2FPython%2Fcpython.git Fix a possible refleak in tupleobject.c (GH-19018) (cherry picked from commit c81609e44eed641d3b8a137daa31ef35501c1f85) Co-authored-by: Hai Shi --- diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index fc2d2742dd2c..bd580946b7eb 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -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);