Skip to content

Commit 7992a29

Browse files
[3.13] GH-140058: Clear key and value if PyTuple_New fails in dictiter_iternextitem (GH-140059) (#140108)
GH-140058: Clear key and value if `PyTuple_New` fails in `dictiter_iternextitem` (GH-140059) (cherry picked from commit ded59f7) Co-authored-by: Sergey Miryanov <[email protected]>
1 parent 7e40d94 commit 7992a29

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Objects/dictobject.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5611,8 +5611,11 @@ dictiter_iternextitem(PyObject *self)
56115611
}
56125612
else {
56135613
result = PyTuple_New(2);
5614-
if (result == NULL)
5614+
if (result == NULL) {
5615+
Py_DECREF(key);
5616+
Py_DECREF(value);
56155617
return NULL;
5618+
}
56165619
PyTuple_SET_ITEM(result, 0, key);
56175620
PyTuple_SET_ITEM(result, 1, value);
56185621
}

0 commit comments

Comments
 (0)