https://github.com/python/cpython/commit/2142f4efcffcf19ce776d2e27e9781c300e852ec commit: 2142f4efcffcf19ce776d2e27e9781c300e852ec branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: kumaraditya303 <[email protected]> date: 2025-10-14T19:10:30+05:30 summary:
[3.14] GH-140058: Clear key and value if `PyTuple_New` fails in `dictiter_iternextitem` (GH-140059) (#140107) GH-140058: Clear key and value if `PyTuple_New` fails in `dictiter_iternextitem` (GH-140059) (cherry picked from commit ded59f7e8e93274488584574ff2336a98bc4eff6) Co-authored-by: Sergey Miryanov <[email protected]> files: M Objects/dictobject.c diff --git a/Objects/dictobject.c b/Objects/dictobject.c index d669f8421c4792..80a44a87be4c4f 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -5670,8 +5670,11 @@ dictiter_iternextitem(PyObject *self) } else { result = PyTuple_New(2); - if (result == NULL) + if (result == NULL) { + Py_DECREF(key); + Py_DECREF(value); return NULL; + } PyTuple_SET_ITEM(result, 0, key); PyTuple_SET_ITEM(result, 1, value); } _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
