Commit 37f001f4 authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #3660 (part of): fix a memory leak in _pickle.

Patch by Amaury Forgeot d'Arc, review by me.
parent 9e7ed395
...@@ -80,6 +80,8 @@ C API ...@@ -80,6 +80,8 @@ C API
Library 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 #3160: the "bdist_wininst" distutils command didn't work.
- Issue #1658: tkinter changes dict size during iteration in both - Issue #1658: tkinter changes dict size during iteration in both
......
...@@ -3837,13 +3837,17 @@ load_build(UnpicklerObject *self) ...@@ -3837,13 +3837,17 @@ load_build(UnpicklerObject *self)
if (setstate == NULL) { if (setstate == NULL) {
if (PyErr_ExceptionMatches(PyExc_AttributeError)) if (PyErr_ExceptionMatches(PyExc_AttributeError))
PyErr_Clear(); PyErr_Clear();
else else {
Py_DECREF(state);
return -1; return -1;
}
} }
else { else {
PyObject *result; PyObject *result;
/* The explicit __setstate__ is responsible for everything. */ /* 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); result = unpickler_call(self, setstate, state);
Py_DECREF(setstate); Py_DECREF(setstate);
if (result == NULL) if (result == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment