diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-03-15 19:55:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-15 19:55:39 (GMT) |
commit | 890dcfe4035888f70207eaac05662d6e29606214 (patch) | |
tree | 6d9325da74e72d4e6d4a963984214c8638580f4c /Objects/tupleobject.c | |
parent | f7e32fcbd65490c921e1836c2399827d14d0eb7b (diff) | |
download | cpython-890dcfe4035888f70207eaac05662d6e29606214.zip cpython-890dcfe4035888f70207eaac05662d6e29606214.tar.gz cpython-890dcfe4035888f70207eaac05662d6e29606214.tar.bz2 |
Fix a possible refleak in tupleobject.c (GH-19018)
(cherry picked from commit c81609e44eed641d3b8a137daa31ef35501c1f85)
Co-authored-by: Hai Shi <shihai1992@gmail.com>
Diffstat (limited to 'Objects/tupleobject.c')
-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 fc2d274..bd58094 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); |