summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2008-09-05 00:03:33 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2008-09-05 00:03:33 (GMT)
commitd79dc6216cf062a3eb0c100f8b546bf0a867e450 (patch)
tree3b25ddd5c88c10c517c42a56e4ce0886c912847e /Modules/_pickle.c
parent9252287f2c9bc09fdc6bc729e13ac63935e4976e (diff)
downloadcpython-d79dc6216cf062a3eb0c100f8b546bf0a867e450.zip
cpython-d79dc6216cf062a3eb0c100f8b546bf0a867e450.tar.gz
cpython-d79dc6216cf062a3eb0c100f8b546bf0a867e450.tar.bz2
Issue #3660 (part of): fix a memory leak in _pickle.
Patch by Amaury Forgeot d'Arc, review by me.
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c6
1 files changed, 5 insertions, 1 deletions
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)