diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 3a2e8bc4aa69e3..9f92d0e99a1e58 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -3123,6 +3123,7 @@ batch_dict(PickleState *state, PicklerObject *self, PyObject *iter) if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 2) { PyErr_SetString(PyExc_TypeError, "dict items " "iterator must return 2-tuples"); + Py_DECREF(obj); return -1; } i = save(state, self, PyTuple_GET_ITEM(obj, 0), 0);