Fix a possible refleak in tupleobject.c (GH-19018)
(cherry picked from commit c81609e44e
)
Co-authored-by: Hai Shi <shihai1992@gmail.com>
This commit is contained in:
parent
f7e32fcbd6
commit
890dcfe403
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue