]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990)
authorJustin Applegate <70449145+Legoclones@users.noreply.github.com>
Tue, 19 Nov 2024 16:00:35 +0000 (11:00 -0500)
committerGitHub <noreply@github.com>
Tue, 19 Nov 2024 16:00:35 +0000 (18:00 +0200)
If PyObject_SetItem() fails in the `load_build()` function of _pickle.c, no DECREF for the `dict` variable.

Modules/_pickle.c

index 5837cd41a40cd4893295d666a3f4fcfcb54c59e6..2696f38046121f1d91069b7801e870602d6595ec 100644 (file)
@@ -6730,6 +6730,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);