]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 19 Nov 2024 18:19:18 +0000 (19:19 +0100)
committerGitHub <noreply@github.com>
Tue, 19 Nov 2024 18:19:18 +0000 (20:19 +0200)
If PyObject_SetItem() fails in the `load_build()` function of _pickle.c, no DECREF for the `dict` variable.
(cherry picked from commit 29cbcbd73bbfd8c953c0b213fb33682c289934ff)

Co-authored-by: Justin Applegate <70449145+Legoclones@users.noreply.github.com>
Modules/_pickle.c

index 179500d6956a78c08c96b394809e78347231c85a..b8f701c2af2e676dcf270c0d3770e572ef96dff0 100644 (file)
@@ -6726,6 +6726,7 @@ load_build(PickleState *st, UnpicklerObject *self)
             }
             if (PyObject_SetItem(dict, d_key, d_value) < 0) {
                 Py_DECREF(d_key);
+                Py_DECREF(dict);
                 goto error;
             }
             Py_DECREF(d_key);