https://github.com/python/cpython/commit/153221a1d050a74f1cfbb7af69232cb92bf505ba
commit: 153221a1d050a74f1cfbb7af69232cb92bf505ba
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-11-19T20:19:18+02:00
summary:

[3.12] gh-126991: Fix reference leak in loading pickle's opcode BUILD 
(GH-126990) (GH-127019)

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 <[email protected]>

files:
M Modules/_pickle.c

diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 179500d6956a78..b8f701c2af2e67 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -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);

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to