diff options
author | Hai Shi <shihai1992@gmail.com> | 2020-03-15 19:37:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-15 19:37:49 (GMT) |
commit | c81609e44eed641d3b8a137daa31ef35501c1f85 (patch) | |
tree | 5c8b67295025809c3e64e03a01fb3441d7296902 /Objects | |
parent | 8689209e0338943dba9b7ff5566b8a420374764c (diff) | |
download | cpython-c81609e44eed641d3b8a137daa31ef35501c1f85.zip cpython-c81609e44eed641d3b8a137daa31ef35501c1f85.tar.gz cpython-c81609e44eed641d3b8a137daa31ef35501c1f85.tar.bz2 |
Fix a possible refleak in tupleobject.c (GH-19018)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/tupleobject.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 14ab53f..839667a 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); |