Fix a possible refleak in tupleobject.c (GH-19018)

This commit is contained in:
Hai Shi 2020-03-16 03:37:49 +08:00 committed by GitHub
parent 8689209e03
commit c81609e44e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -737,8 +737,10 @@ tuple_subtype_new(PyTypeObject *type, PyObject *iterable)
return NULL; return NULL;
assert(PyTuple_Check(tmp)); assert(PyTuple_Check(tmp));
newobj = type->tp_alloc(type, n = PyTuple_GET_SIZE(tmp)); newobj = type->tp_alloc(type, n = PyTuple_GET_SIZE(tmp));
if (newobj == NULL) if (newobj == NULL) {
Py_DECREF(tmp);
return NULL; return NULL;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
item = PyTuple_GET_ITEM(tmp, i); item = PyTuple_GET_ITEM(tmp, i);
Py_INCREF(item); Py_INCREF(item);