Skip to content

Commit c81609e

Browse files
authored
Fix a possible refleak in tupleobject.c (GH-19018)
1 parent 8689209 commit c81609e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Objects/tupleobject.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,10 @@ tuple_subtype_new(PyTypeObject *type, PyObject *iterable)
737737
return NULL;
738738
assert(PyTuple_Check(tmp));
739739
newobj = type->tp_alloc(type, n = PyTuple_GET_SIZE(tmp));
740-
if (newobj == NULL)
740+
if (newobj == NULL) {
741+
Py_DECREF(tmp);
741742
return NULL;
743+
}
742744
for (i = 0; i < n; i++) {
743745
item = PyTuple_GET_ITEM(tmp, i);
744746
Py_INCREF(item);

0 commit comments

Comments
 (0)