From 29cbcbd73bbfd8c953c0b213fb33682c289934ff Mon Sep 17 00:00:00 2001 From: Justin Applegate <70449145+Legoclones@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:00:35 -0500 Subject: [PATCH] gh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990) If PyObject_SetItem() fails in the `load_build()` function of _pickle.c, no DECREF for the `dict` variable. --- Modules/_pickle.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 5837cd41a40cd4..2696f38046121f 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -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);