Skip to content

Commit 2142f4e

Browse files
[3.14] pythonGH-140058: Clear key and value if PyTuple_New fails in dictiter_iternextitem (pythonGH-140059) (python#140107)
pythonGH-140058: Clear key and value if `PyTuple_New` fails in `dictiter_iternextitem` (pythonGH-140059) (cherry picked from commit ded59f7) Co-authored-by: Sergey Miryanov <[email protected]>
1 parent 45577c9 commit 2142f4e

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
@@ -5670,8 +5670,11 @@ dictiter_iternextitem(PyObject *self)
56705670
}
56715671
else {
56725672
result = PyTuple_New(2);
5673-
if (result == NULL)
5673+
if (result == NULL) {
5674+
Py_DECREF(key);
5675+
Py_DECREF(value);
56745676
return NULL;
5677+
}
56755678
PyTuple_SET_ITEM(result, 0, key);
56765679
PyTuple_SET_ITEM(result, 1, value);
56775680
}

0 commit comments

Comments
 (0)