summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_pickle.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 889cead..1bb4f6f 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -80,6 +80,8 @@ C API
Library
-------
+- Issue #3660: fix a memory leak in the C accelerator of the pickle module.
+
- Issue #3160: the "bdist_wininst" distutils command didn't work.
- Issue #1658: tkinter changes dict size during iteration in both
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index ea5bbe2..f7b5212 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -3837,13 +3837,17 @@ load_build(UnpicklerObject *self)
if (setstate == NULL) {
if (PyErr_ExceptionMatches(PyExc_AttributeError))
PyErr_Clear();
- else
+ else {
+ Py_DECREF(state);
return -1;
+ }
}
else {
PyObject *result;
/* The explicit __setstate__ is responsible for everything. */
+ /* Ugh... this does not leak since unpickler_call() steals the
+ reference to state first. */
result = unpickler_call(self, setstate, state);
Py_DECREF(setstate);
if (result == NULL)