]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-122311: Fix a refleak in pickle (GH-122411) (GH-122416)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 29 Jul 2024 19:10:46 +0000 (21:10 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Jul 2024 19:10:46 +0000 (19:10 +0000)
(cherry picked from commit 68840e91ac6689d3954b98a9ab136e194b5250b8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Modules/_pickle.c

index 4986809957204edbbae3caa5a57cfcdf93e6756f..96534a565b3a833f58920ba5961e0c58f6c9d60e 100644 (file)
@@ -3188,6 +3188,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);